Forum Discussion
Connecting Semantic Model to Cloud Data Source via API
As of the last update, the official Power BI REST API documentation does not explicitly document the process of managing cloud data source connections directly through the Power BI REST API, including the process of programmatically assigning those connections to semantic models.
While there may not be documentation support for the specific endpoint you want to query.
However, the Power BI REST API provides the following methods for updating data source credentials and updating data sources.
Gateways - Update Datasource - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Datasets - Update Datasources - REST API (Power BI Power BI REST APIs) | Microsoft Learn
I also found some relevant documentation on how to create and share cloud data sources and connect to cloud data sources in power bi service.
Create and share cloud data sources in the Power BI service - Power BI | Microsoft Learn
Connect to cloud data sources in the Power BI service - Power BI | Microsoft Learn
I hope you find it helpful.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- accountingbob2 years agoNew Member
Thank you for your reply. I have been using the update datasource enpoints to update the username and password previously, but I can't find a way to list the "gateways" for the cloud data sources. I have tried the https://api.powerbi.com/v1.0/myorg/gateways endpoint and it returns an empty list. If I pull a semantic model which is already connected to the cloud datasource, the result does contain a gatewayId, but when I then try to get that gateway using https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}, I get a 404 result.
- tlecomte2 years agoNew Member
We are having that problem here as well.
Our use case is about updating credentials for a shared cloud connection that is used in a OneLake shortcut. We would like to do that programmatically, on a schedule. For non-shared connections, so far we were successful with https://learn.microsoft.com/en-us/rest/api/power-bi/gateways/update-datasource, but not for shared cloud connections.
We've looked at the network requests and responses that happen when we navigate the Power BI UI at https://app.powerbi.com/groups/me/gateways . We noticed that there is gatewayId that is used for all of them, for a gateway that is of the "TenantCloud" type, and each of these shared cloud connections has a datasourceId. However, as mentioned by accountingbob, https://api.powerbi.com/v1.0/myorg/gateways does not return that gateway id. We also tried to use these gateway id and datasource id in https://learn.microsoft.com/en-us/rest/api/power-bi/gateways/update-datasource, but that leads to an Unauthorized error.
So we are in the same situation: we cannot use the existing API to update the credentials of a shared cloud connection. The impact for us is that it is blocking us from using OneLake shortcuts, since we would have to rely on someone manually updating credentials in the UI, and that's not robust enough.
- mforte2 years agoNew Member
Same situation, did you find a solution?
- foodd2 years agoCommunity Champion
Issues
If you have found a true bug or issue, you can make a post to the forum to let others know (and that would be very nice of you to do so). But if you want to get it fixed, you should post it in the Issues/Ideas (it varies) area of the community. Specifically, you should post it here:
Power BI - https://community.powerbi.com/t5/Issues/idb-p/Issues
PowerAutomate - https://powerusers.microsoft.com/t5/I-Found-A-Bug/bd-p/BugFound
PowerApps - https://ideas.powerapps.com
Ideas
If you have a new idea for functionality or how something should work, you can certainly start a thread on the community to solicit feedback on your idea, but you should also post the idea in the ideas section of the website and solicit others to vote on your idea. The development teams use the Ideas area of the communities to build their development pipeline and a significant amount of weight is placed on Ideas that have lots of votes versus those that do not. The ideas areas of the communities are here:
Power BI - https://ideas.powerbi.com
PowerAutomate - https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas
PowerApps - https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas
- Pseud0nym1 year agoFrequent Visitor
I found that when I already have a semantic model connected to my cloud connection I can call Datasets - Get Datasources In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn and get both the datasourceId and the gatewayId (gateway here is a misnomer as it is just an id for the cloud connection).
I can then use these values on any semantic model I like using Datasets - Bind To Gateway In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn. If the sql server and database are the same as in that first semantic model, it will have the same datasourceId for that data source. This means I only have to set it manually in one of my semantic models then I can use the api to deploy any other semantic model using the same source.