I am trying to set a Databricks access key credential in a Power BI datasource through REST API calls.
I own the dataset and can set the key through the Power BI service web UI (app.powerbi.com)
But when I try to do this through REST APIs (e.g., with curl
) I am getting stuck
I found my way to the datasource via the dataset:
https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/datasources
Then I got a response back like
{
"@odata.context":"http://wabi-us-east2-c-primary-redirect.analysis.windows.net/v1.0/myorg/groups/xxx/$metadata#datasources","value":[
{
"datasourceType":"Extension","connectionDetails":{
"path":"{\"host\":\"adb-xxxx.xx.azuredatabricks.net\",\"httpPath\":\"\\/sql\\/1.0\\/warehouses\\/xxxx\"}","kind":"Databricks"
},"datasourceId":"xxxxx","gatewayId":"xxxx"
}
]
}
Using this response I tried making a call like this
PATCH https://api.powerbi.com/v1.0/myorg/gateways/xxxx/datasources/xxxx
with body:
{
"credentialDetails": "{\"credentialData\":[{\"name\":\"key\", \"value\":\"dapiXXXXX-X\"}]}",
"credentialType": "Key",
"privacyLevel": "None",
"encryptionAlgorithm": "None"
}
And I get back this error:
{"error":{"code":"UnknownError","pbi.error":{"code":"UnknownError","parameters":{},"details":[],"exceptionCulprit":1}}}%
I think I saw something about encrypting the credentials but I am unable to get the Gateway public key through the APIs (/myorg/gateways returned empty list); and anyhow this is a cloud resource, not using an on-prem gateway, and I am able to set credentials through the web UI.
What am I missing, or doing wrong?
It turned out to be oversight on my part. I forgot -H "Content-Type: application/json"
on my curl
command.
SMH.