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
sergei
Frequent Visitor

REST API: change PostgreSQL datasource database

Is there a way to use the REST API to change the PostgreSQL datasource, specifically, change its database and server address?

 

Here is what I am doing:

  • I create a report in Power BI desktop, which imports data from a PostgreSQL datasource through an on-premised gateway. 
  • I upload the pbix report to the Power BI cloud service using the REST API (for use in Power BI Embedded).
  • I now need to switch the database from a staging DB to the production DB

The Update Datasources In Group API documentation says that it can only be used with "SQL Server, Azure SQL Server, Analysis Services, Azure Analysis Services, OData Feed, and SharePoint datasources. For other datasource types, use Update Parameters In Group".

 

The aforementioned Update Parameters In Group API requires that "All parameters must exist in the dataset." However, my dataset does not have any parameters, as far as I can tell, so I get errors when I try to set any parameters:

 

error.png

 

I can see the connection details using the Get Datasources In Group API (screenshot below). Is there any way to change them?

 

datasource.PNG

 

 

 

1 ACCEPTED SOLUTION
sergei
Frequent Visitor

I figured out an answer to my own question, and want to share it with anyone else who gets stuck on this. 

 

The Update Parameters In Group API call is the right approach. However, the dataset needs to be set up in advance to hold the database and server address in parameters, which can then be modified using the API. 

 

To set up the data source with parameters, click Edit Queries within Power BI Desktop. There is an Edit Parameters option there. Create parameters with your connection info. Then, under Edit Queries > Data source settings, Change the data source to use these parameters instead of explicitly specifying the connection strings. Here is a screenshot:

 

 

params.PNG

Hope this helps!

View solution in original post

1 REPLY 1
sergei
Frequent Visitor

I figured out an answer to my own question, and want to share it with anyone else who gets stuck on this. 

 

The Update Parameters In Group API call is the right approach. However, the dataset needs to be set up in advance to hold the database and server address in parameters, which can then be modified using the API. 

 

To set up the data source with parameters, click Edit Queries within Power BI Desktop. There is an Edit Parameters option there. Create parameters with your connection info. Then, under Edit Queries > Data source settings, Change the data source to use these parameters instead of explicitly specifying the connection strings. Here is a screenshot:

 

 

params.PNG

Hope this helps!

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.