Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I can execute a patch request to set the credentials of a online directquery datasource using the HttpClient class with no problem. But now I'm looking for a way to do this using the classes of the Microsoft.PowerBI.Api NuGet Package but I cannot find what method to use. I did find a class named GatewayDatasource which looks like the json payload for a patch. But that is as far as I've come...
Thanks
Gunter
Solved! Go to Solution.
Hi!
use:
m_client.Gateways.UpdateDatasource(<gatewayId>, <datasourceId>, <request>);
where request is
- request {Microsoft.PowerBI.Api.V2.Models.UpdateDatasourceRequest} Microsoft.PowerBI.Api.V2.Models.UpdateDatasourceRequest
- CredentialDetails {Microsoft.PowerBI.Api.V2.Models.CredentialDetails} Microsoft.PowerBI.Api.V2.Models.CredentialDetails
CredentialType "Basic" string
Credentials "{\"credentialData\":[{\"name\":\"username\",\"value\":\"<username>\"},{\"name\":\"password\",\"value\":\"<password>"}]}" string
EncryptedConnection "Encrypted" string
EncryptionAlgorithm "None" string
PrivacyLevel "None" string
Eli.
Hi!
use:
m_client.Gateways.UpdateDatasource(<gatewayId>, <datasourceId>, <request>);
where request is
- request {Microsoft.PowerBI.Api.V2.Models.UpdateDatasourceRequest} Microsoft.PowerBI.Api.V2.Models.UpdateDatasourceRequest
- CredentialDetails {Microsoft.PowerBI.Api.V2.Models.CredentialDetails} Microsoft.PowerBI.Api.V2.Models.CredentialDetails
CredentialType "Basic" string
Credentials "{\"credentialData\":[{\"name\":\"username\",\"value\":\"<username>\"},{\"name\":\"password\",\"value\":\"<password>"}]}" string
EncryptedConnection "Encrypted" string
EncryptionAlgorithm "None" string
PrivacyLevel "None" string
Eli.
What should be the values for gatewayId and datasourceId?
If you are providing the credentials for an Azure SQL or Azure Table Storage datasource, these things do not require an on-premise gateway to access.
The V2 API (at least via Nuget) does not return any datasource objects when you request a dataset - therefore no datasource id can be provided.
Gateways.GetGateways (or whatever it is called) returns nothing... as I have no on-prem gateways!
Hi.
For cloud data sources, there is a default gateway created by Power BI.
To find out the gateway and datasource ids, use this call: GetBoundGatewayDatasources (https://msdn.microsoft.com/en-us/library/mt732874.aspx)
The SDK equivalent are Datasets.GetGatewayDatasources or Datasets.GetGatewayDatasourcesInGroup
Eli.
Can you please elaborate on what values should be provided for gatewayId and datasourceId? v-ljerr-msft responded with the same block of code in my request (https://community.powerbi.com/t5/Developer/How-to-update-credentials-of-a-connection-with-V2-API-in-...) but I think you guys are only providing half the answer here.
My datasource is Azure SQL (*NOT* Analysis Services), but I'd also like this to work for Azure Table Storage.
I can use the Microsoft.PowerBI.Api.V2 classes to:
The Dataset object has a Datasources property. However this is NULL. So I find myself at a dead end!
A few other frustrations...
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
4 | |
4 | |
3 | |
3 | |
3 |