Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
I am using powershell for .pbix to deployment in workspaces. As part of that i need to create SQL datasource under gateway for further use. I am using powerbI rest API with service principle : https://learn.microsoft.com/en-us/rest/api/power-bi/gateways/create-datasource
Here is link for sample we can use in powershell: https://community.powerbi.com/t5/Developer/Power-BI-REST-API-via-Powershell-Create-Datasource/m-p/51...
I hope someone can help me here. Thanks in advance.
API I am seding request:
POST https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources
Request message Body:
{
"connectionDetails": "{\"server\":\"MyServer\",\"database\":\"MyDatabase\"}",
"datasourceName": "Test_dateasource",
"dataSourceType": "Sql",
"credentialDetails": {
"credentialType": "Basic",
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "RSA-OAEP",
"privacyLevel": "Organizational",
"credentials": "W3....=="
}
}
Response from API:
{
"error": {
"code": "DM_GWPipeline_UnknownError",
"pbi.error": {
"code": "DM_GWPipeline_UnknownError",
"parameters": {},
"details": [
{
"code": "DM_ErrorDetailNameCode_UnderlyingErrorMessage",
"detail": {
"type": 1,
"value": "The parameter is incorrect.\r\n"
}
},
{
"code": "DM_ErrorDetailNameCode_UnderlyingHResult",
"detail": {
"type": 1,
"value": "-2146893785"
}
}
],
"exceptionCulprit": 1
}
}
}
I've got the same problem.
Just gonna keep an eye here, in case you figure it out.
I am able to solve this problem, In my case credential encryption was not correct. using owershell i was not able to encrypt credentials correctly.
To solve this i used C# code from below sample to encrypt credentials. So I created C# console application and use that .exe to encrypt credentials.
https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/.NET%20Core/EncryptCredentials
Assuming you have a Pro license you can consider raising a Pro ticket at https://powerbi.microsoft.com/en-us/support/pro/
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |