cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Dan2 Frequent Visitor
Frequent Visitor

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

Accepted Solutions
Dan2 Frequent Visitor
Frequent Visitor

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

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"
     }
  ]
}

1 REPLY 1
Dan2 Frequent Visitor
Frequent Visitor

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

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"
     }
  ]
}