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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
muhammed24
Regular Visitor

Problem in Update Datasource Power BI REST API Call

https://learn.microsoft.com/en-us/rest/api/power-bi/gateways/update-datasource

The Power BI REST API call mentioned above is a PATCH request that is used to change/update the datasource credentials.

 

Request body is the credentialDetails, whose format is different for different credentials type.

For basic credentials with username and password, it looks like the following - 

{ "credentialDetails": { "credentialType": "Basic", "credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"john\"},{\"name\":\"password\", \"value\":\"*****\"}]}", "encryptedConnection": "Encrypted", "encryptionAlgorithm": "None", "privacyLevel": "None", "useEndUserOAuth2Credentials": "False" } }

 

For on-premise encrypted credentials - 

{ "credentialDetails": { "credentialType": "Windows", "credentials": "AB....EF==", "encryptedConnection": "Encrypted", "encryptionAlgorithm": "RSA-OAEP", "privacyLevel": "None" } }

 

The problem I am facing is that the credentials I want to update is On-premise with "Windows" credential type with username and password. But I am not able to find the right json format for such a request. If anyone can help, please.

 

power BI rest API with python  Power BI REST API Update datasource credentials 

1 ACCEPTED SOLUTION
muhammed24
Regular Visitor

I found the answer. For using WIndows credentials, first the credentials need to be encrypted to a credential string.

The python example is given here - https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/Python/Encrypt%20credentials

 

View solution in original post

5 REPLIES 5
muhammed24
Regular Visitor

I found the answer. For using WIndows credentials, first the credentials need to be encrypted to a credential string.

The python example is given here - https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/Python/Encrypt%20credentials

 

Anonymous
Not applicable

Hey @muhammed24 did you try to use the following format?

 

 "credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"john\"},{\"name\":\"password\", \"value\":\"*****\"}]}"

 

Let me know if this works:)  

@Anonymous 

I tried your format. It is not working. Gave an PrimitiveValue error. Then I tried the same format within curly brackets and I get the following error.

{
  "error": {
    "code": "BadRequest",
    "message": "Bad Request",
    "details": [
      {
        "message": "The property 'credentials' does not exist on type 'Microsoft.PowerBI.ServiceContracts.Api.GatewayDatasource'. Make sure to only use property names that are defined by the type.",
        "target": "datasourceDelta"
      }
    ]
  }
}

 

 

Anonymous
Not applicable

I see. This means that with "credentialtype" Windows we are not allow to use the format above. Did you try with Basic Credentials? https://learn.microsoft.com/en-us/rest/api/power-bi/gateways/update-datasource#basic-credentials-exa...

@Anonymous  Yes I did. I tried various combinations too, it didn't work. But I learnt that we have to encrypt the Windows Username and password into a single string and use that as credential. So I am now trying to find the way to do that encryption in Python. (I made a new question)

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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