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
Anonymous
Not applicable

Can't add data source to data gateway with rest API

hello,
I have problem with adding data source to data gateway using rest API
according to documentation available here:
https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/createdatasource
and here:
https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/updatedatasource#basic_credentials_examp...

using powershell I created a simple script
that should add new datasource to a data gateway unfortunately it always finish with http error 400 (bad request)

script:

$postParams = [ordered]@{
"dataSourceType" = "SQL"
"connectionDetails" = @{"server" = $dbServerName; "database" = $dbName } 
"credentialDetails" = [ordered]@{
"credentialType" = "Basic"
"credentials"= @{
"credentialData" = @(
[ordered]@{"name" = "username"; "value" = $dbUserName },[ordered]@{"name" = "password"; "value" = $dbUserPwd }
)
}
"encryptedConnection"= "Encrypted"
"encryptionAlgorithm"= "None"
"privacyLevel"= "None"

}
"datasourceName"= $datasourceName
}
$jsonPostBody = $postParams | ConvertTo-JSON -Depth 99

$uri = "https://api.powerbi.com/v1.0/myorg/gateways/$($gatewayID)/datasources"
$datasource = Invoke-RestMethod -Uri $uri -Headers $auth_header -Method POST -Body $jsonPostBody

is it some missing information i documentation or am I doing something wrong?

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

I would suggest you to create a support ticket here.

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

hi @v-yuta-msft,

I filed a ticket and it was successfully submitted (Case 119052922001462) unfortunately after 24h  I didn't get any feedback/contact from Support

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.

Top Solution Authors
Top Kudoed Authors