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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Advocate II
Advocate 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.