Datasets - Update Datasources In Group

Updates the datasources of the specified dataset from the specified workspace.

Important:

  • The original datasource and the new datasource must have the exact same schema.
  • For cached models, the dataset must be refreshed to get the data from the new datasources. Wait 30 minutes for the update datasources operation to complete before refreshing.


Required scope: Dataset.ReadWrite.All
To set the permissions scope, see Register an app.

Restrictions

  • Update datasources supports SQL Server, Azure SQL Server, Analysis Services, Azure Analysis Services, OData Feed, and SharePoint datasources. For other datasource types, use Update Parameters In Group.
  • Changing datasource type is not supported.
  • Datasources that contain parameters on the connection string are not supported.
  • Datasources which are part of Merged or Joined tables are not supported.

POST https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetKey}/Default.UpdateDatasources

URI Parameters

Name In Required Type Description
groupId
path True
  • string

The workspace id

datasetKey
path True
  • string

Request Body

Name Required Type Description
updateDetails

The connection server

Responses

Name Type Description
200 OK

OK

Examples

example

Sample Request

POST https://api.powerbi.com/v1.0/myorg/groups/f089354e-8366-4e18-aea3-4cb4a3a50b48/datasets/cfafbeb1-8037-4d0c-896e-a46fb27ff229/Default.UpdateDatasources
{
  "updateDetails": [
    {
      "datasourceSelector": {
        "datasourceType": "Sql",
        "connectionDetails": {
          "server": "My-Sql-Server",
          "database": "My-Sql-Database"
        }
      },
      "connectionDetails": {
        "server": "New-Sql-Server",
        "database": "New-Sql-Database"
      }
    },
    {
      "datasourceSelector": {
        "datasourceType": "OData",
        "connectionDetails": {
          "url": "http://services.odata.org/V4/Northwind/Northwind.svc"
        }
      },
      "connectionDetails": {
        "url": "http://services.odata.org/V4/Odata/Northwind.svc"
      }
    }
  ]
}

Sample Response

Definitions

Datasource

A Power BI datasource

DatasourceConnectionDetails

A Power BI datasource connection details

Object
UpdateDatasourceConnectionRequest
UpdateDatasourcesRequest

Datasource

A Power BI datasource

Name Type Description
connectionDetails

The datasource connection details

connectionString
  • string

The datasource connection string. Available only for DirectQuery.

datasourceId
  • string

The bound datasource id. Empty when not bound to a gateway.

datasourceType
  • string

The datasource type

gatewayId
  • string

The bound gateway id. Empty when not bound to a gateway.

name
  • string

The datasource name. Available only for DirectQuery.

DatasourceConnectionDetails

A Power BI datasource connection details

Name Type Description
database
  • string

The connection database

server
  • string

The connection server

url
  • string

The connection url

Object

UpdateDatasourceConnectionRequest

Name Type Description
connectionDetails
datasourceSelector

UpdateDatasourcesRequest

Name Type Description
updateDetails

The connection server