Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Creating a Datasource on the gateway with windows credentials using RESTApi is failing with 400 err

Can anyone help me on the below

We are trying to automate the Datasource creation in Gateways using Powershell script and Rest API but the rest api post method keeps on failing with the error Status Code: BadRequest (400)

We have followed the below ms doc for the rest api 

https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/createdatasource 

 

We want to create the new Analysis services data source using windows credentials and unable to to figure out what should exactly go into windows cred details in json

The below code is provided in the MS doc 

Sample request for Analysis Services

{ "dataSourceType": "AnalysisServices", "connectionDetails": "{\"server\":\"MyServer\",\"database\":\"MyDatabase\"}", "datasourceName": "Sample Datasource", "credentialDetails": { "credentialType": "Windows", "credentials": "AB....EF==", "encryptedConnection": "Encrypted", "encryptionAlgorithm": "RSA-OAEP", "privacyLevel": "None" } }

 

We tested with the following code snippets

1)

{
"datasourceType":"AnalysisServices",
"connectionDetails":"{\"server\":\"xxxxx\\\\xxxxx\",\"database\":\"TESTDB\"}","credentialDetails":{
"credentialType": "Windows",
"credentials": "AB....EF==",                                         -->Not sure what should be added here
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "RSA-OAEP",
"privacyLevel": "None"
},"datasourceName":"Testing"

}

 

2)

{
"datasourceType":"AnalysisServices",
"connectionDetails":"{\"server\":\"xxxxx\\\\xxxxx\",\"database\":\"TESTDB\"}","credentialDetails":{
"credentialType": "Windows",
"credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"contoso\\john\"},{\"name\":\"password\", \"value\":\"*****\"}]}" ---->   Tried with my windows cred  and it's returning 400 err
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "RSA-OAEP",
"privacyLevel": "None"
},"datasourceName":"Testing"

}

 

Please help me in getting what should be added or modified in the above JSON BODY

 

 

 

 

 

 

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello Henry,

       

      Thank you for the reposnse.

      We are trying to create the datasource in Power BI Data Gateway using any Cli tools as we have to automate this through Azure DevOps.

       

      We found only doc for the Powerbi rest api provided by Microsoft https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/createdatasource and trying to invoke it using Powershell Cli tool and also the same can be acheived in Azure DevOps using Powershell cli task.

       

      As per my understanding ZappySys Tool doesnt have any Cli to achieve the same as i mentioned above.

      But Please correct me if I'm wrong.