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
Dan2
Helper I
Helper I

How to update the datasource target odata url using the powerbi rest api

We currently deploy the same dashboard to multiple environments, (ie, dev, test, prod). These dashboards all pull from an odata api so the URL for the target data willl change for each environment. So for the deployment process we use the rest api to upload the pbix files, but also want to change the api target url for the dashboard based on the environment it is being deployed too.

 

In trying to use the "updatedatasource" rest api call it states this can be used for an odata feed to update it, but gives no example for this. I have been trying to get this to work with the api it gives a 500 error or a 400 bad request based upon different tries to make this work. From other discussion boards, this may not even be possible. And trying to find a decent example out there for this so far has been a futile effort. I have done this successfully using direct query dashboards which require a user/password. So I understand how to use the api successfully but for the updatedatasource have been unsuccessful with changing a url.

 

So was wondering if anyone has done this and can share some code. And maybe is this even possible and as per below url it makes me think it might not even be possible. Thanks.

https://community.powerbi.com/t5/Integrations-with-Files-and/How-to-refresh-using-REST-API-with-OAut...

 

Microsoft updatedatsource info

https://msdn.microsoft.com/en-us/library/mt814715.aspx#request

 

Below is the url and code example I have been using.

POST https://api.powerbi.com/v1.0/myorg/groups/{mygroupidhere}/datasets/{mydatasetidhere}/updatedatasourc...

API - body 

 {
    "updateDetails":[
       {
          "datasourceSelector":
               {
                 "datasourceType": "OData",
                 "connectionDetails":
                        {
                             "url":"https://mydomain.com/mydirectory/odata"
                        }
                }
         }
     ]
}

1 ACCEPTED SOLUTION
Dan2
Helper I
Helper I

So after reformatting I was able to successfully change the api url. Below is the example for anyone doing this.

{
"updateDetails":[
    {
      "connectionDetails":
         {
              "url":"https://dev.mydomain.com/yourdirectory/odata"
        },
             "datasourceType": "OData"
     }
  ]
}

View solution in original post

1 REPLY 1
Dan2
Helper I
Helper I

So after reformatting I was able to successfully change the api url. Below is the example for anyone doing this.

{
"updateDetails":[
    {
      "connectionDetails":
         {
              "url":"https://dev.mydomain.com/yourdirectory/odata"
        },
             "datasourceType": "OData"
     }
  ]
}

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.