Forum Discussion
Use a Service Principal to deploy a PowerBI report against Databricks OAuth with Direct Query
Please refer to this documentation and update the credential for DirectQuery.
Configure credentials programmatically for Power BI embedded analytics - Power BI | Microsoft Learn
- amirskiy1 year agoNew Member
Yes, refered to Power BI REST API. Below you can find sample code.
$body = @{ credentialDetails = @{ credentialType = 'Basic' credentials = @{ credentialData = @( @{ name = 'username'; value = $username }, @{ name = 'password'; value = $password } ) } | ConvertTo-Json encryptedConnection = 'Encrypted' encryptionAlgorithm = 'None' privacyLevel = 'Organizational' useEndUserOAuth2Credentials = $true } } | ConvertTo-Json -Depth 6 $datasourePatchUrl = "https://api.powerbi.com/v1.0/myorg/gateways/$gatewayId/datasources/$datasourceId" Invoke-RestMethod -Method Patch -Uri $datasourePatchUrl -Body $body -Headers $headers -ContentType $contentTypeThe error is:
{ "error": { "code": "InvalidRequest", "message": "Property useEndUserOAuth2Credentials is only supported with credentials of type Basic and datasource type of Extension" } }
But actually both conditions are met. Credentials type is Basic. Datasource type is Extension (can be easily checked via another API call).
It seems that the API is not actually implemented, and the error message is misleading.Please advise.
- amirskiy1 year agoNew Member
Yes, refered to Power BI REST API. Below you can find sample code.
$body = @{ credentialDetails = @{ credentialType = 'Basic' credentials = @{ credentialData = @( @{ name = 'username'; value = $username }, @{ name = 'password'; value = $password } ) } | ConvertTo-Json encryptedConnection = 'Encrypted' encryptionAlgorithm = 'None' privacyLevel = 'Organizational' useEndUserOAuth2Credentials = $true } } | ConvertTo-Json -Depth 6 $datasourePatchUrl = "https://api.powerbi.com/v1.0/myorg/gateways/$gatewayId/datasources/$datasourceId" Invoke-RestMethod -Method Patch -Uri $datasourePatchUrl -Body $body -Headers $headers -ContentType $contentTypeThe error is:
{ "error": { "code": "InvalidRequest", "message": "Property useEndUserOAuth2Credentials is only supported with credentials of type Basic and datasource type of Extension" } }
But actually both conditions are met. Credentials type is Basic. Datasource type is Extension (can be easily checked via another API call).
It seems that the API is not actually implemented, and the error message is misleading.Please advise.