Datasets - Update Datasources

Updates the datasources of the specified dataset from "My 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 data sources. 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
  • 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/datasets/{datasetId}/Default.UpdateDatasources

URI Parameters

Name In Required Type Description
datasetId
path True
  • string

The dataset id

Request Body

Name Required Type Description
updateDetails True

The connection server

Responses

Name Type Description
200 OK

OK

Examples

example

Sample Request

POST https://api.powerbi.com/v1.0/myorg/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

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

UpdateDatasourceConnectionRequest

Name Type Description
connectionDetails
datasourceSelector

UpdateDatasourcesRequest

Name Type Description
updateDetails

The connection server