Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
riyajshaikh09
Frequent Visitor

Issue while creating data source under Data Gateway using powershell

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

 

 

 



3 REPLIES 3
PierreHusted
New Member

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

 

 

lbendlin
Super User
Super User

Assuming you have a Pro license you can consider raising a Pro ticket at https://powerbi.microsoft.com/en-us/support/pro/

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.