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

Pragmatically Change Datasets Data source Credential

Hi,

 

I've publish a report into a workspace that we use for development.  To migrate the report from the Dev Worspace to an UAT one, I've build a PowerShell script that import the report.  In the script, I'm changing the database connection of the dataset to point to the UAT server and database using the report parameters (not a gateway).  The issue that I'm now facing is that I also need to change the data source credential of the dataset since the user that we use in UAT is not the same then Dev.

 

How can I change those information using the API or use User Id and User Password parameters ?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

Re: Pragmatically Change Datasets Data source Credential

Hi,

I been able to change the data source credit using the UpdateDataSource API (https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/updatedatasource).

 

The trick is to use the Get Datasource (https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/getdatasourcesingroup) before to retrieve the GatewayId and the DatasourceId link to the Dataset.  Even if you didn't declare a Gateway to your Dataset (For direct link to SQL Server in Azure), there is one created in the background and link to a Datasource.

 

So, after calling the Get Datasource, I have all required information to call the UpdateDataSource and change the user Id and credential to connect to the new connection.

 

Issue solve.

 

Thanks

View solution in original post

2 REPLIES 2
Highlighted
Resident Rockstar
Resident Rockstar

Re: Pragmatically Change Datasets Data source Credential

Highlighted
Frequent Visitor

Re: Pragmatically Change Datasets Data source Credential

Hi,

I been able to change the data source credit using the UpdateDataSource API (https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/updatedatasource).

 

The trick is to use the Get Datasource (https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/getdatasourcesingroup) before to retrieve the GatewayId and the DatasourceId link to the Dataset.  Even if you didn't declare a Gateway to your Dataset (For direct link to SQL Server in Azure), there is one created in the background and link to a Datasource.

 

So, after calling the Get Datasource, I have all required information to call the UpdateDataSource and change the user Id and credential to connect to the new connection.

 

Issue solve.

 

Thanks

View solution in original post

Helpful resources

Announcements
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!