Forum Discussion

quybmt2003's avatar
quybmt2003
New Member
6 years ago

Update dataset datasource as in group via rest api with InvalidRequest code response

Hello,

 

I'm trying to update the data source in a dataset that is following microsoft instruction but unfortunately, I'm reveiving the error from api response. anybody can help me with this. here is my request and response. thank you so much.

 

Request:

uri: https://api.powerbi.com/v1.0/myorg/groups/groupid/datasets/datasetid/Default.UpdateDatasources

 {
  "updateDetails": [
    {
      "connectionDetails": {
        "server""updating server",
        "database""updating database"
      },
      "datasourceSelector": {
        "datasourceType""Sql",
        "connectionDetails": {
              "server""origin server",
              "database""origin database"
        }
      }
    }
  ]
}
 
Response:
Bad request
{
    "error": {
        "code""InvalidRequest",
        "message""The datasource of selector 1 matches one of the target datasources in the request."
    }
}

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi quybmt2003 

    The request object looks ok to me.

    A couple of things to check...

    The docs on this (and code that I have used in the past), has the ordering of the JSON defined differently. I would like to think that this wouldn't make a difference BUT you never know. It's worth trying placing the datasourceSelector above the connectionDetails object.

    More importantly... changing a datasource can take time before it shows up in the Power BI service or API calls.
    Is it possible that the data sources have been modified and it is subsequent update requests that are failing? I have hit this issue myself in the past. The documentation has often stated that it can take 30mins for a connection change to take effect.

    In my experience - it is much faster than this.

    You can use this endpoint to fetch the current connection details: https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/getdatasourcesingroup