Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
oyermokhin
Regular Visitor

Rest API Update Datasource returns an error when using UseCallerAADIdentity

Hi All!

 

I have automated process that is uploading reports and datasource from pbix to PowerBI service. After datasource is there I'm trying to update credentials. I use UseCallerAADIdentity attribute during Update Datasource call (https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/update-datasource). The api call returns error 500. With only one line in payload "Error occured". 

 

I use following body:

 

"credentialDetails" = @{
"credentialType" = "OAuth2"
"useCallerAADIdentity" = "True"
"encryptedConnection" = "Encrypted"
"encryptionAlgorithm" = "None"
"privacyLevel" = "Private"
 
Does anybody know what is wrong here?
 
I can also see that the parameter seems to be correct accoring these tests - https://github.com/microsoft/PowerBI-CSharp/blob/master/sdk/PowerBI.Api.Tests/CredentialsTests.cs
Line 71.
 

 

I have found a similar question that is without answer:

https://community.powerbi.com/t5/Developer/Rest-API-Update-Datasource-UseCallerAADIdentity-or/td-p/7...

4 REPLIES 4
ed-freeman
Helper II
Helper II

Hey @oyermokhin,

 

Did you ever figure this one out?

 

Trying to do something similar for a cloud SQL DB, but keep getting either 500s (when I omit `credentials` altogether), or 400s (when I set `credentials` to null or an empty object).

 

The docs are pretty thin on the ground, so it's not entirely clear which sources this can be used on. It says "For Extension data sources, don't set useCallerAADIdentity to true". Then it says "To set OAuth 2.0 credentials for other data sources, send the OAuth 2.0 token in the payload as shown in the OAuth 2.0 credentials example."    

 

So I can't use it for Extension data sources. And for other sources I need to specify the bearer token myself. I wonder - when can I actually use useCallerAADIdentity  then? 😅

 

If you know any more on this and are happy to share, that would be great.

 

Thanks,

 

Ed

oyermokhin
Regular Visitor

Hi  @v-shex-msft

I'm sorry for late feedback this. Thanks you for your answer. 

 

I previosly have tried to execute GetDatasources REST Api call to check the parameters, but the response does not help me. Here is a response

 

 

 

 @odata.context : http://wabi-north-europe-redirect.analysis.windows.net/v1.0/myorg/groups/........../$metadata#datasources value : {@ {datasourceType=Extension; connectionDetails=; datasourceId=...............; gatewayId=.....} } 

 

 

I also tried to get information about my datasource

with following endpoint 

GET https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources/{datasourceId}
This return following: 

 

 

@odata.context    : http://wabi-north-europe-redirect.analysis.windows.net/v1.0/myorg/$metadata#gatewayDatasources/$entity
id                : ....
gatewayId         : ....
datasourceType    : Extension
connectionDetails : {"extensionDataSourceKind":"AzureDataExplorer","extensionDataSourcePath":"https://.....westeurope.kusto.windows.net"}
credentialType    : OAuth2
credentialDetails : @{useEndUserOAuth2Credentials=False} 

 

 

 

To give you more context I would say that I have used Kusto connector and the credentials object should be empty if theuseCallerAADIdentity is set to true. The idea is to use the AAD identity of the calling (app that will embed the report) application. 

@oyermokhin : I am having a similar requirement where i need to update credentials for Azure Data Explorer data source through Power BI Rest API call in a powershell script. Were you successful in your approach ? If yes, do share the solution for this.

v-shex-msft
Community Support
Community Support

Hi @oyermokhin,

I think this error may mean you have used the invalid request contents of the API.
For this scenario, I'd like to suggest you use the get data source API to get the detail data source configurations then you can modify them with new credentials.

Datasets - Get Datasources - REST API (Power BI Power BI REST APIs) | Microsoft Docs

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.