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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Dan2
Helper I
Helper I

Unable to update user-password using API UpdateDatasourceWithHttpMessagesAsync

We moved the dashboards from v1 (workspace collections) to v2 (app workspaces). In doing so we have a deployment process that called the c# powerbi API to update the datasource username/passwords. In V1 there was a PatchDatasource method. In V2 this is non-existant. In V2 there is a UpdateDatasourceWithHttpMessagesAsync which I have tried to use but unsuccessful.

 

I have so far found no actual examples of how to call this successfully. I have found several forum posts but none if this is fruitful. 

 

The closest example was found at https://community.powerbi.com/t5/Developer/How-do-I-update-the-Credentials-after-I-upload-a-report-t...

This example provides a separate method to encrypt basic credential but gives no information on how to find the gateway public key or gateway public key modulus. In trying to query for the gateway using the c# api method GetGatewaysWithHttpMessagesAsync this always returns zero gateways. So cannot go any futher using this partial example.

 

The other url's which I have looked at where other users are wanting to find the gateway public keys or having issues with updating the datasource credentials are below. And I see the same similar issues I am addressing above.

https://community.powerbi.com/t5/Developer/Update-Credentials-C/m-p/271635

https://community.powerbi.com/t5/Developer/Automating-Power-BI-Gateway-administration-by-using-Power...

 

So the main question, is there a full code example of where this has been successfully done that can be reviewed? 

 

Thanks.

1 ACCEPTED SOLUTION
Dan2
Helper I
Helper I

For anyone who is having the same issue I found the below url which is a c# code that is a full example. I had to modfiy the code to fit my scenario, but it helped resolve the issue of updating the datasource. I had to manually call the rest calls as could not get the C# API to do this.

 

https://github.com/CriticalPathTraining/PbixInstallerForPowerBI

 

View solution in original post

2 REPLIES 2
Dan2
Helper I
Helper I

For anyone who is having the same issue I found the below url which is a c# code that is a full example. I had to modfiy the code to fit my scenario, but it helped resolve the issue of updating the datasource. I had to manually call the rest calls as could not get the C# API to do this.

 

https://github.com/CriticalPathTraining/PbixInstallerForPowerBI

 

Hi Dan,

 

Glad you found a solution.

 

It is disappointing that no-one from Microsoft has come along and provided an official answer or, better yet,provided  a decent update to the documentation and code samples for the V2 API - especially since they are sending out emails to users of the Azure Workspaces API notifying them that it will be switched off in a few months!

 

I will note however that the Microsoft.PowerBi.Api Nuget package was updated a couple of days ago, so maybe that has better support for this?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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