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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

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
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.