cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jimmcslim Member
Member

How to update credentials of a connection with V2 API in package Microsoft.PowerBI.Api 2.0.10?

Is it possible to use the Power BI V2 API to update connection details (e.g. set the connection username and password) using the Nuget package Microsoft.PowerBI.Api 2.0.10? Primarily interested in setting the connection details of either Azure SQL or Azure Table Storage connections in PBIX that I have imported through my custom front-end.

 

This package has namespaces for both the V1 and V2 APIs... are the issues with using both in an application?

 

 

2 REPLIES 2
Highlighted
v-ljerr-msft Super Contributor
Super Contributor

Re: How to update credentials of a connection with V2 API in package Microsoft.PowerBI.Api 2.0.10?

Hi @jimmcslim,

 

Have you tried using the UpdateDatasourceAsync function within Nuget package Microsoft.PowerBI.Api to update cloud source credentials in your scenario? The code below is for your reference. Smiley Happy

                var credentialDetails = new CredentialDetails();
                credentialDetails.CredentialType = "Basic";
                credentialDetails.Credentials = "";
                var updateDatasourceRequest = new UpdateDatasourceRequest(credentialDetails);
                await client.Gateways.UpdateDatasourceAsync("gatewayId", "datasourceId", updateDatasourceRequest);

 

Regards

jimmcslim Member
Member

Re: How to update credentials of a connection with V2 API in package Microsoft.PowerBI.Api 2.0.10?

Sorry, but your sample doesn't really help me.

 

In the context of an Azure SQL (not Analysis Services, and not on-prem) or Azure Table Storage datasource, what should be the value of gatewayId and datasourceId? How do I use the REST API/Nuget package to get these values? I have tried to use the IPowerBIClient.Groups, IPowerBIClient.Reports, and IPowerBIClient.Datasets APIs to enumerate the objects and while I can lookup groups, reports and datasets, there are no datasources linked to my dataset and no gateways in my IPowerBIClient.Gateways call.

 

Maybe best to take the discussion to the linked issue below, which was similar to a question of mine.

 

https://community.powerbi.com/t5/Developer/Patching-an-Online-DirectQuery-datasource/m-p/351230

 

(Unfortunately it appears my response to the above thread has been squashed).