Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Animus
New Member

How to serialize credentials in order to create a PBI Databricks datasource using API?

Hello I;m trying to create a PBI datasource using API (connecting via data gateway). I was trying to serialize my credentials like the following example before i encrypt them and add them to the body for the api:

serialized_credentials = '{\'credentialData\':[{\'name\':\'key\',\'value\':\'' + token + '\'}]}'

 

unfortunatelly the api raises error: 

{'code': 'Microsoft.Data.Mashup.MashupSecurityException.Reason', 'detail': {'type': 1, 'value': 'CredentialMissing'}}], 'exceptionCulprit': 1}}}

 

api body:

{
"connectionDetails": "****",
"credentialDetails": {
"credentials": "XX=",
"credentialType": "Key",
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "RSA-OAEP",
"privacyLevel": "Organizational"
},
"datasourceName": "test",
"dataSourceType": "Extension"
}

anyone had the same problem? 

6 REPLIES 6
Animus
New Member

Hi @Anonymous , I'm working to finish CI/CD pipeline and manual in not accepted as a solution. 

Animus
New Member

Hello @Anonymous , thank you for the reply. 
This format is not working unfortunatelly. works perfectly for update the of the datasource , but not for the creation of a new one. 

Anonymous
Not applicable

Hi, @Animus 

Sorry for not helping you a lot.

If you don't fit to create an API, as you said, you'll have to create a new data source manually. Sign in to the Power BI portal, navigate to Data source settings, In the left navigation, select the Settings icon, and then select Manage gateways. Select the data source type, and in the Data source type drop-down menu, select Azure Databricks to configure the connection details.

vyohuamsft_0-1733128524050.png

When you use Azure Databricks as a data source for Power BI Online, you can also create Power BI datasets from tables or schemas directly from the Databricks UI. You can check the following link:

vyohuamsft_1-1733128772196.png

Connect Power BI to Azure Databricks - Azure Databricks | Microsoft Learn

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi, @Animus 

Your error message indicates that your credentials are missing or formatted incorrectly. Make sure that you are using the gateway's public key to properly encrypt the serialized credentials. Also verify that your data gateway is configured correctly and that the public key used for encryption matches the public key expected by the gateway.
Refer to the official Power BI REST API documentation for detailed instructions on creating data sources and handling credentials:

Power BI REST APIs for embedded analytics and automation - Power BI REST API | Microsoft Learn

 

Gateways - Create Datasource - REST API (Power BI Power BI REST APIs) | Microsoft Learn

 

Power BI REST API v1 | Documentation | Postman API Network

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous Thank you for reply. The encyrption works for SQL (creating and updating) and for updating an existing databricks connection. this is happening only when I create a new connection. If I mannually create the connection from the portal there is no error.
Per documentation the above serialization is what should be working.

Anonymous
Not applicable

Hi, @Animus 

Have you solved your problem? 

Maybe you can check your code format:

serialized_credentials = '{"credentialData":[{"name":"key","value":"' + token + '"}]}'

You also can refer to this post:

vyohuamsft_0-1733127233469.png

Solved: How to use Service Principal to connect PowerBI to... - Databricks Community - 7023

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.