cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mattia_b Frequent Visitor
Frequent Visitor

Gateways - Create Datasource Rest and SDK problems

I'm trying to create a new datasource and bind it to a gateway,

when submit the request via C # sdk
the result is:
       $ exception {"Operation returned an invalid status code 'BadRequest'"}

 

exploring the request the body is:

{r "dataSourceType": "Sql", "connectionDetails": "{server" command ":" \ t "," database "": - "<MY_DB>>", "credential Details": {credentials: {\ _ "credentialData \ _": [{v - name "name": \ _ username "username", \ t \ _\ "}, {\ _ \ _" name \ _\ ": \ _ password \ _ password", \ _ "value \ _" \ t }, "credential type": "Basic", "encrypted connection": "Encrypted", "encryption algorithm": - RSA - OAEP, "privacyLevel": "None", n "data SourceName": "datasource - from code" n}

which is not really a perfect json.

 

 

Later I tried REST API on the page:
https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/createdatasource

the request body is:
{ "DataSourceType": "SQL", "connectionDetails": "{\" server \ ": \" <MY_DB_SERVER> \ ", \" database \ ": \" <my_db> \ "}", "credentialDetails": { "credentialType": "Basic", "credentials": "{\" credentialData \ ": [{\" name \ ": \" username \ ", \" value \ ": \" <MY_USERNAME> \ "}, { \ "name \": \ "password \", \ "value \": \ "<MY_PSW> \"}]} "," encryptedConnection "," Encrypted "," encryptionAlgorithm ":" RSA-OAEP, "" privacyLevel ":" None ",}," DataSourceName ":" datasource-from-rest "}

and the result was:
Response Code: 400
requestid: 6b3ea5a3-eefa-4dc4-b979-5561c890f578
{
  "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 since it contains a non-Base 64 character, more than two fill characters or an incorrect character between the fill characters."
          }
        },
        {
          "code": "DM_ErrorDetailNameCode_UnderlyingHResult",
          "detail": {
            "type": 1,
            "value": "-2146233033"
          }
        }
      ]
    }
  }
}

I would like to be able to add programmatimaente datasources to a gateway but there seems to be some problem, can anyone help me?

thanks for your attention

1 ACCEPTED SOLUTION

Accepted Solutions
mattia_b Frequent Visitor
Frequent Visitor

Re: Gateways - Create Datasource Rest and SDK problems

2 REPLIES 2
mattia_b Frequent Visitor
Frequent Visitor

Re: Gateways - Create Datasource Rest and SDK problems

After much research it seems that the problem is the need to crypt the credentials. Unfortunately this thing is not mentioned in the main API guide but only in the paragraph: 

https://docs.microsoft.com/en-us/power-bi/developer/encrypt-credentials


Now my problem is how to find (or calculate) the values: "publicKeyExponent" and "publicKeyModulus" which should be related to the public gatewey key.

Confident in someone's help, thanks for your attention.

 

 

mattia_b Frequent Visitor
Frequent Visitor

Re: Gateways - Create Datasource Rest and SDK problems

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,310)