Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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 

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hey Anonymous did you try to use the following format?

     

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

     

    Let me know if this works:)  

    • Anonymous's avatar
      Anonymous
      Not applicable

      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"
            }
          ]
        }
      }