Gateways - Create Datasource

Creates a new data source on the specified gateway.

To encrypt credentials, see Configure credentials programmatically.

Permissions

The user must have gateway admin permissions.

Required scope

Dataset.ReadWrite.All

Limitations

Virtual network (VNet) gateways aren't supported.

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

URI Parameters

Name In Required Type Description
gatewayId
path True
  • string
uuid

The gateway ID. When using a gateway cluster, the gateway ID refers to the primary (first) gateway in the cluster. In such cases, gateway ID is similar to gateway cluster ID.

Request Body

Name Required Type Description
connectionDetails True
  • string

The connection details

credentialDetails True

The credential details

dataSourceName True
  • string

The data source name

dataSourceType True
  • string

The data source type

Responses

Name Type Description
201 Created

Created

Examples

Analysis Services
SQL

Analysis Services

Sample Request

POST https://api.powerbi.com/v1.0/myorg/gateways/1f69e798-5852-4fdd-ab01-33bb14b6e934/datasources
{
  "dataSourceType": "AnalysisServices",
  "connectionDetails": "{\"server\":\"MyServer\",\"database\":\"MyDatabase\"}",
  "datasourceName": "Sample Datasource",
  "credentialDetails": {
    "credentialType": "Windows",
    "credentials": "AB....EF==",
    "encryptedConnection": "Encrypted",
    "encryptionAlgorithm": "RSA-OAEP",
    "privacyLevel": "None"
  }
}

Sample Response

SQL

Sample Request

POST https://api.powerbi.com/v1.0/myorg/gateways/1f69e798-5852-4fdd-ab01-33bb14b6e934/datasources
{
  "dataSourceType": "SQL",
  "connectionDetails": "{\"server\":\"MyServer\",\"database\":\"MyDatabase\"}",
  "datasourceName": "Sample Datasource",
  "credentialDetails": {
    "credentialType": "Windows",
    "credentials": "AB....EF==",
    "encryptedConnection": "Encrypted",
    "encryptionAlgorithm": "RSA-OAEP",
    "privacyLevel": "None"
  }
}

Sample Response

Definitions

CredentialDetails

The credential details

credentialType

The type of data source credentials

encryptedConnection

Whether to encrypt the data source connection. The API call will fail if you select encryption and Power BI is unable to establish an encrypted connection with the data source.

encryptionAlgorithm

The encryption algorithm. For a cloud data source, specify None. For an on-premises data source, specify RSA-OAEP and use the gateway public key.

GatewayDatasource

A Power BI gateway data source

GatewayDatasourceCredentialDetails

The data source credential details

privacyLevel

The privacy level, which is relevant when combining data from multiple sources.

PublishDatasourceToGatewayRequest

A publish data source to gateway request

CredentialDetails

The credential details

Name Type Description
credentialType

The credential type

credentials
  • string

The credentials, which depend on the 'credentialType' value. For more information, see Update Datasource examples.

encryptedConnection

Whether to encrypt the data source connection. The API call will fail if you select encryption and Power BI is unable to establish an encrypted connection with the data source.

encryptionAlgorithm

The encryption algorithm. For a cloud data source, specify None. For an on-premises data source, specify RSA-OAEP and use the gateway public key.

privacyLevel

The privacy level, which is relevant when combining data from multiple sources.

useCallerAADIdentity
  • boolean

Use to indicate that the Azure AD identity (OAuth2 credentials) of the API caller (which must be the data source owner) will be used to configure data source credentials (the owner OAuth access token). Typically, you’d either use this flag or useEndUserOAuth2Credentials.

useEndUserOAuth2Credentials
  • boolean

Use with data sources that support single sign-on (SSO) to indicate that the end-user Azure AD identity (OAuth2 credentials) is used for connecting to the data source in DirectQuery mode. Typically, you’d either use this flag or useCallerAADIdentity.

credentialType

The type of data source credentials

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

encryptedConnection

Whether to encrypt the data source connection. The API call will fail if you select encryption and Power BI is unable to establish an encrypted connection with the data source.

Name Type Description
Encrypted
  • string
NotEncrypted
  • string

encryptionAlgorithm

The encryption algorithm. For a cloud data source, specify None. For an on-premises data source, specify RSA-OAEP and use the gateway public key.

Name Type Description
None
  • string
RSA-OAEP
  • string

GatewayDatasource

A Power BI gateway data source

Name Type Description
connectionDetails
  • string

Connection details in JSON format

credentialDetails

The connection details for the data source that needs update. The connection details are mandatory when the dataset has more than one data source.

credentialType

The type of data source credentials

datasourceName
  • string

The name of the data source

datasourceType
  • string

The type of data source.

API name for the data source
ActiveDirectory AdobeAnalytics AdoDotNet
AnalysisServices AzureBlobs AzureDataLakeStorage
AzureMarketplace AzureTables BizTalk
CDPA CustomConnector CustomHttpApi
DB2 Essbase EventHub
Excel Exchange Extension
Facebook File Folder
GoogleAnalytics Hdfs HDInsight
Informix MQ MySql
OData ODBC OleDb
Oracle PostgreSql PowerQueryMashup
PubNub Salesforce SAPBW
SAPBWMessageServer SapErp SAPHana
SharePoint SharePointDocLib SharePointList
Sql Sybase Teradata
UIFlow Web
gatewayId
  • string

The associated gateway ID. When using a gateway cluster, the gateway ID refers to the primary (first) gateway in the cluster and is similar to the gateway cluster ID.

id
  • string

The unique ID for the data source

GatewayDatasourceCredentialDetails

The data source credential details

Name Type Description
useEndUserOAuth2Credentials
  • boolean

Use with data sources that support single sign-on (SSO) to indicate that the end-user Azure AD identity (OAuth2 credentials) is used for connecting to the data source in DirectQuery mode.

privacyLevel

The privacy level, which is relevant when combining data from multiple sources.

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

PublishDatasourceToGatewayRequest

A publish data source to gateway request

Name Type Description
connectionDetails
  • string

The connection details

credentialDetails

The credential details

dataSourceName
  • string

The data source name

dataSourceType
  • string

The data source type