Gateways - Update Datasource

Updates the credentials of the specified datasource from the specified gateway.

To get the gateway and datasource ids for a dataset, use Get Datasources or Get Datasources In Group

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

PATCH https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources/{datasourceId}

URI Parameters

Name In Required Type Description
gatewayId
path True
  • string

The gateway id

datasourceId
path True
  • string

The datasource id

Request Body

Name Required Type Description
credentialDetails

The credential details

Responses

Name Type Description
200 OK

OK

Examples

Anonymous credentials example
Basic credentials example
Key credentials example
OAuth2 credentials example
Windows credentials example

Anonymous credentials example

Sample Request

PATCH https://api.powerbi.com/v1.0/myorg/gateways/1f69e798-5852-4fdd-ab01-33bb14b6e934/datasources/252b9de8-d915-4788-aaeb-ec8c2395f970
{
  "credentialDetails": {
    "credentialType": "Anonymous",
    "credentials": "{\"credentialData\":\"\"}",
    "encryptedConnection": "Encrypted",
    "encryptionAlgorithm": "None",
    "privacyLevel": "None"
  }
}

Sample Response

Basic credentials example

Sample Request

PATCH https://api.powerbi.com/v1.0/myorg/gateways/1f69e798-5852-4fdd-ab01-33bb14b6e934/datasources/252b9de8-d915-4788-aaeb-ec8c2395f970
{
  "credentialDetails": {
    "credentialType": "Basic",
    "credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"john\"},{\"name\":\"password\", \"value\":\"*****\"}]}",
    "encryptedConnection": "Encrypted",
    "encryptionAlgorithm": "None",
    "privacyLevel": "None"
  }
}

Sample Response

Key credentials example

Sample Request

PATCH https://api.powerbi.com/v1.0/myorg/gateways/1f69e798-5852-4fdd-ab01-33bb14b6e934/datasources/252b9de8-d915-4788-aaeb-ec8c2395f970
{
  "credentialDetails": {
    "credentialType": "Key",
    "credentials": "{\"credentialData\":[{\"name\":\"key\", \"value\":\"ec....LA=\"}]}",
    "encryptedConnection": "Encrypted",
    "encryptionAlgorithm": "None",
    "privacyLevel": "None"
  }
}

Sample Response

OAuth2 credentials example

Sample Request

PATCH https://api.powerbi.com/v1.0/myorg/gateways/1f69e798-5852-4fdd-ab01-33bb14b6e934/datasources/252b9de8-d915-4788-aaeb-ec8c2395f970
{
  "credentialDetails": {
    "credentialType": "OAuth2",
    "credentials": "{\"credentialData\":[{\"name\":\"accessToken\", \"value\":\"eyJ0....fwtQ\"}]}",
    "encryptedConnection": "Encrypted",
    "encryptionAlgorithm": "None",
    "privacyLevel": "None"
  }
}

Sample Response

Windows credentials example

Sample Request

PATCH https://api.powerbi.com/v1.0/myorg/gateways/1f69e798-5852-4fdd-ab01-33bb14b6e934/datasources/252b9de8-d915-4788-aaeb-ec8c2395f970
{
  "credentialDetails": {
    "credentialType": "Windows",
    "credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"contoso\\john\"},{\"name\":\"password\", \"value\":\"*****\"}]}",
    "encryptedConnection": "Encrypted",
    "encryptionAlgorithm": "None",
    "privacyLevel": "None"
  }
}

Sample Response

Definitions

CredentialDetails

The credential details

credentialTypeEnum

Type of the datasoruce credentials

encryptedConnectionEnum

Should Power BI allow fallback to unencrypted if the target server doesn't support encryption

encryptionAlgorithmEnum

The encryption algorithm. For cloud datasource, use 'None'. For on-premises datasource, use gateway public key with 'RSA-OAEP' algorithm.

Object
privacyLevelEnum

The privacy level. Relevant when combining data from multiple sources.

UpdateDatasourceRequest

An update datasource to gateway request

CredentialDetails

The credential details

Name Type Description
credentialType

The credential type

credentials
  • string

The credentials. Depends on the 'credentialType' value. See Update Datasource Examples.

encryptedConnection

Should Power BI allow fallback to unencrypted if the target server doesn't support encryption

encryptionAlgorithm

The encryption algorithm. For cloud datasource, use 'None'. For on-premises datasource, use gateway public key with 'RSA-OAEP' algorithm.

privacyLevel

The privacy level. Relevant when combining data from multiple sources.

useCallerAADIdentity
  • boolean

Should the caller's AAD identity be used for OAuth2 credentials configuration

useEndUserOAuth2Credentials
  • boolean

Should the end-user OAuth2 credentials be used for connecting to the datasource in DirectQuery mode. Only supported for Direct Query to SQL Azure.

credentialTypeEnum

Type of the datasoruce credentials

Name Type Description
Anonymous
  • string
Basic
  • string
Key
  • string
OAuth2
  • string
Windows
  • string

encryptedConnectionEnum

Should Power BI allow fallback to unencrypted if the target server doesn't support encryption

Name Type Description
Encrypted
  • string
NotEncrypted
  • string

encryptionAlgorithmEnum

The encryption algorithm. For cloud datasource, use 'None'. For on-premises datasource, use gateway public key with 'RSA-OAEP' algorithm.

Name Type Description
None
  • string
RSA-OAEP
  • string

Object

privacyLevelEnum

The privacy level. Relevant when combining data from multiple sources.

Name Type Description
None
  • string
Organizational
  • string
Private
  • string
Public
  • string

UpdateDatasourceRequest

An update datasource to gateway request

Name Type Description
credentialDetails

The credential details