Forum Discussion
How to enter SQL server credentials via API?
Hi robzib ,
The first step is to add the gateway connection information. But, to encrypt credentials, see Configure credentials programmatically for Power BI and review the EncryptCredentials .NET Core, Java and Python examples.
POST https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources
Gateways - Create Datasource - REST API (Power BI Power BI REST APIs) | Microsoft Docs
Part 2, get the newly added datasource from the result of step 1.
GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/datasources
Datasets - Get Datasources In Group - REST API (Power BI Power BI REST APIs) | Microsoft Docs
Part 3, get the connection information from part 2 and use Update Datasources In Group.
GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/datasources
Datasets - Get Datasources In Group - REST API (Power BI Power BI REST APIs) | Microsoft Docs
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
so I've decided to test gateways and see if I can make them work with the help of your links, and I'm stuck at Add data source step. I think the issue is connection details because I'm getting Bad request every time. Parameters that I'm sending are:
Data Source Type: "SQL"
Connection details: "{"server":"dell0\\dbi","database":"dbi6452"}"
Credential type: "Basic credentials"
I'm trying to do that from EncryptCredentials.sln example you attached. Google returned a couple of threads with same issues and I can't find a working example. I'm also not sure in what format should connection details be, this is copy and paste from app.powerbi when I do it via GUI over there.
Also, gateway needs to be installed with service principal account or else I can't see it with Rest API, but I managed to get some instructions online about that so that part works now.
Any help is appreciated.