Gateways - Update Datasource

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

Required scope: Dataset.ReadWrite.All

  • To set the permissions scope, see Register an app
  • To encrypt credentials, see Encrypt credentials
  • PATCH https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources/{datasourceId}

    URI Parameters

    Name In Required Type Description
    datasourceId
    path True
    • string
    uuid

    The datasource id

    gatewayId
    path True
    • string
    uuid

    The gateway id

    Request Body

    Name Required Type Description
    credentialDetails True

    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

    credentialType

    Type of the datasoruce credentials

    encryptedConnection

    User input for this attribute is currently ignored. Today, regardless of the provided value, we always try to establish an encrypted connection first but fall back to an unencrypted option in case of a failure.
    This will be fixed for the following data source types with the June 2019 gateway release causing a value of Encrypted to try only an encrypted connection and NotEncrypted with an unencrypted connection and there would be no fallback behavior

    • Impala
    • MySql
    • DB2
    • Netezza
    • PostgreSQL
    • Sybase
    • Teradata
    • GoogleBigQuery
    • Amazon Redshift

    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.

    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

    User input for this attribute is currently ignored. Today, regardless of the provided value, we always try to establish an encrypted connection first but fall back to an unencrypted option in case of a failure.
    This will be fixed for the following data source types with the June 2019 gateway release causing a value of Encrypted to try only an encrypted connection and NotEncrypted with an unencrypted connection and there would be no fallback behavior

    • Impala
    • MySql
    • DB2
    • Netezza
    • PostgreSQL
    • Sybase
    • Teradata
    • GoogleBigQuery
    • Amazon Redshift

    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.

    credentialType

    Type of the datasoruce credentials

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

    encryptedConnection

    User input for this attribute is currently ignored. Today, regardless of the provided value, we always try to establish an encrypted connection first but fall back to an unencrypted option in case of a failure.
    This will be fixed for the following data source types with the June 2019 gateway release causing a value of Encrypted to try only an encrypted connection and NotEncrypted with an unencrypted connection and there would be no fallback behavior

    • Impala
    • MySql
    • DB2
    • Netezza
    • PostgreSQL
    • Sybase
    • Teradata
    • GoogleBigQuery
    • Amazon Redshift

    Name Type Description
    Encrypted
    • string
    NotEncrypted
    • string

    encryptionAlgorithm

    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

    privacyLevel

    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