Forum Discussion

Animus's avatar
Animus
New Member
1 year ago

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

  • 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's avatar
      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.

      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:

      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's avatar
    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.

    • Animus's avatar
      Animus
      New Member

      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.

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