Gateways - Create Datasource
Creates a new data source on the specified on-premises gateway.
On premises data source credentials must be encrypted. The encryptedConnection
parameter must be set to Encrypted
and the credentials should be encrypted using the gateway public key.
See the Create Gateway DataSource PowerShell script for an example of using this API, this script uses the PowerShell script mentioned in the note below for encrypting the credentials.
Note
To encrypt credentials, see Configure credentials programmatically for Power BI and review the EncryptCredentials .NET Core, Java, Python and PowerShell examples.
Permissions
Supports only on-premises gateways and the user must have gateway admin permissions
Required Scope
Dataset.ReadWrite.All
Limitations
- Virtual network (VNet) and Cloud gateways aren't supported.
- OAuth2 as a credential type isn't supported.
POST https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
gateway
|
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
Azure Analysis Services example |
SQL example |
Azure Analysis Services example
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 example
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
Name | Description |
---|---|
Credential |
The credential details |
credential |
The type of data source credential |
encrypted |
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. |
encryption |
The encryption algorithm. For a cloud data source, specify |
Gateway |
A Power BI gateway data source |
Gateway |
The data source credential details |
privacy |
The privacy level, which is relevant when combining data from multiple sources. |
Publish |
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 |
|
privacyLevel |
The privacy level, which is relevant when combining data from multiple sources. |
|
useCallerAADIdentity |
boolean |
Whether the Azure AD identity (OAuth 2.0 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 would either use this flag or |
useEndUserOAuth2Credentials |
boolean |
Whether the end-user Azure AD identity (OAuth 2.0 credentials) is used when connecting to the data source in DirectQuery mode. Use with data sources that support single sign-on (SSO). Typically, you would either use this flag or |
credentialType
The type of data source credential
Name | Type | Description |
---|---|---|
Anonymous |
string |
|
Basic |
string |
|
Key |
string |
|
OAuth2 |
string |
|
SAS |
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 to encrypt the credentials.
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 credential |
||||||||||||||||||||||||||||||||||||||||||||||||||||
datasourceName |
string |
The name of the data source |
|||||||||||||||||||||||||||||||||||||||||||||||||||
datasourceType |
string |
The type of data source.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
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 |
Whether the end-user Azure AD identity (OAuth 2.0 credentials) is used when connecting to the data source in DirectQuery mode. Use with data sources that support single sign-on (SSO). |
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 |