cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
sergei Frequent Visitor
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

Accepted Solutions
sergei Frequent Visitor
Frequent Visitor

Re: REST API: change PostgreSQL datasource database

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!

1 REPLY 1
sergei Frequent Visitor
Frequent Visitor

Re: REST API: change PostgreSQL datasource database

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!