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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.