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

Patching an Online DirectQuery datasource

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

1 ACCEPTED SOLUTION

Accepted Solutions
Power BI Team eligr
Power BI Team

Re: Patching an Online DirectQuery datasource

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.

4 REPLIES 4
Power BI Team eligr
Power BI Team

Re: Patching an Online DirectQuery datasource

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.

jimmcslim Member
Member

Re: Patching an Online DirectQuery datasource

Can you please elaborate on what values should be provided for gatewayId and datasourceIdv-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:

 

  1. Enumerate my groups to find the group id I want by name via IPowerBIClient.Groups.GetGroupsAsync
  2. Enumerate the reports in the group to find the id of the report by name via IPowerBIClient.Reports.GetReportsInGroupAsync
  3. Each of these reports has a DataSetId, ok great, maybe that provides the gateway/datasourceId.
  4. I get the Dataset via IPowerBIClient.Datasets.GetDatasetByIdInGroupAsync

 

The Dataset object has a Datasources property. However this is NULL. So I find myself at a dead end!

 

A few other frustrations...

 

  • Calling IPowerBIClient.Datasets.GetDatasetsAsync returns an empty list. What the? Surely this should at least return the dataset that is returned by #4 above, plus any other datasets in any other reports in any other groups, i.e. all datasets accessible to the authenticated user.
  • Your samples keep talking about a gatewayId, ok then lets call IPowerBIClient.Gateways.GetGatewaysAsync... and I get nothing back (which makes sense, since I don't have any on-prem gateways running/configured, but your samples keep referring to gatewayId - which makes me think we are talking at cross-purposes re datasets using on-prem gateways vs cloud datasources).
jimmcslim Member
Member

Re: Patching an Online DirectQuery datasource

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!

Highlighted
Power BI Team eligr
Power BI Team

Re: Patching an Online DirectQuery datasource

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.

 

Helpful resources

Announcements
Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 157 members 2,263 guests
Please welcome our newest community members: