Datasets - Update Datasources In Group

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

Note: When using this API, it's recommended to use enhanced dataset metadata.

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. If you're not using enhanced dataset metadata, wait 30 minutes for the update datasources operation to complete before refreshing.
Required scope: Dataset.ReadWrite.Al
To set the permissions scope, see Register an app.

Restrictions

  • This operation is only supported for the dataset owner
  • Update datasources supports the following datasource types:
    • SQL Server
    • Azure SQL Server
    • Analysis Services
    • Azure Analysis Services
    • OData Feed
    • SharePoint
    • Oracle
    • Teradata
    • SapHana
    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.
  • If you are not using enhanced dataset metadata, updating datasources which are part of merged or joined tables are not supported. If you are using enhanced dataset metadata, updating datasources which are part of merged or joined tables is supported. However, in an Advanced Query referencing multiple datasources, only the first datasource can be updated. To overcome this limitation, define the datasource as a parameter and then use Update Parameters In Group.

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

URI Parameters

Name In Required Type Description
datasetId
path True
  • string
groupId
path True
  • string
uuid

The workspace 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/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

UpdateDatasourceConnectionRequest
UpdateDatasourcesRequest

Datasource

A Power BI datasource

Name Type Description
connectionDetails

The datasource connection details

connectionString
  • string

(Deprecated) 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

(Deprecated) 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