Forum Discussion
Connecting Semantic Model to Cloud Data Source via API
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.
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.