I am trying to use the Microsoft Power BI API to create a new data source on a gateway https://learn.microsoft.com/en-us/rest/api/power-bi/gateways/createdatasource. To test I am trying to create a connection to an Azure Sql Database with basic authentication. I can add the data source using Power BI online GUI without a problem, however whenever I am trying to use the API I receive a 400 - DMTS_InvalidEncryptionAlgorithmError.
The key field is encryptionAlgorithm in the body, but as stated in the API documentation, it should be "None" for cloud data sources.
I have also tried using "RSA-OAEP", but this gives me a 400 - DM_GWPipeline_UnknownError.
I am currently working with Postman, but I also tried to replicate the same request with NodeJS with the same result.
Any hints towards a solution would be very helpful.
POST https://api.powerbi.com/v1.0/myorg/gateways/00000000-0000-0000-0000-000000000000/datasources
Headers
content-type: application/json,
Autorization: Bearer token
Body
{
"datasourceType": "Sql",
"connectionDetails": "{\"server\":\"servername.database.windows.net\",\"database\":\"dbname\"}",
"credentialDetails": {
"credentialType": "Basic",
"credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"myusername\"},{\"name\":\"password\", \"value\":\"mypwd\"}]}",
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "None",
"privacyLevel": "None"
},
"datasourceName": "new-datasource-name"
}
Error message when using "None" - HTTP 400
{
"error": {
"code": "DMTS_InvalidEncryptionAlgorithmError",
"pbi.error": {
"code": "DMTS_InvalidEncryptionAlgorithmError",
"parameters": {},
"details": [],
"exceptionCulprit": 1
}
}
}
Error message when using "RSA-OAEP" - HTTP 400
{
"error": {
"code": "DM_GWPipeline_UnknownError",
"pbi.error": {
"code": "DM_GWPipeline_UnknownError",
"parameters": {},
"details": [
{
"code": "DM_ErrorDetailNameCode_UnderlyingErrorMessage",
"detail": {
"type": 1,
"value": "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. "
}
},
{
"code": "DM_ErrorDetailNameCode_UnderlyingHResult",
"detail": {
"type": 1,
"value": "-2146233033"
}
}
]
}
}
}