Forum Discussion
How to update connection string for every tenant/client using power bi rest api
Hello All,
we are embedding power bi dashboard using iframe and we have multiple tenants/client where we want to use same dashboard(pbix file) but want to use different datasources as every tenant/client want to see different data in dashboard , we want to pass the connection string to power bi using rest api , is it possible to pass from embeeded application , or is there any rest api ? really looking for help , thanks in advance
Hi. I'm not sure about the request of changing source from the web site. I could work, maybe, depending on the change of the sources but I wouldn't recommend it.
Considering a dataset with pure cloud sources. You can change datasources of a dataset with the power bi rest api:
https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/update-datasources-in-group
However, it's quite limitated for specific sources. If you want to work with a different source from the ones specified at the doc, you could build a parameter of the connection: https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/update-parameters-in-group
You can check videos using parameters for changing excel paths or database names.
Consideration: keep in mind that right after changing a datasource for a new string connection for the first time, for example de server o database name of sql server, the dataset will request setting the credentials to let you refresh the dataset.
On the other hand if you are working with onpremise sources it might be tricky. All sources may want to use the same gateway cluster. Then create the source for the gateway after the user changes it: https://learn.microsoft.com/en-us/rest/api/power-bi/gateways/create-datasource
I hope that helps
1 Reply
- ibarrauSuper User
Hi. I'm not sure about the request of changing source from the web site. I could work, maybe, depending on the change of the sources but I wouldn't recommend it.
Considering a dataset with pure cloud sources. You can change datasources of a dataset with the power bi rest api:
https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/update-datasources-in-group
However, it's quite limitated for specific sources. If you want to work with a different source from the ones specified at the doc, you could build a parameter of the connection: https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/update-parameters-in-group
You can check videos using parameters for changing excel paths or database names.
Consideration: keep in mind that right after changing a datasource for a new string connection for the first time, for example de server o database name of sql server, the dataset will request setting the credentials to let you refresh the dataset.
On the other hand if you are working with onpremise sources it might be tricky. All sources may want to use the same gateway cluster. Then create the source for the gateway after the user changes it: https://learn.microsoft.com/en-us/rest/api/power-bi/gateways/create-datasource
I hope that helps