Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
jimmcslim
Helper III
Helper III

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
v-ljerr-msft
Microsoft Employee
Microsoft Employee

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

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).

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.