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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
IAmStandard
Frequent Visitor

Set Datasource Credential with API - Fabric SQL Endpoint issue

Hi,

 

I'm working on a project where I need to update the credentials of some Dataset programatically. I got it working for SharePoint, Dataverse and Dataflow.

Now i'm trying to do the same for Fabric SQL Endpoint, however I recieve the error below :

 

{
  "error": {
    "code""DM_GWPipeline_Gateway_InvalidConnectionCredentials",
    "pbi.error": {
      "code""DM_GWPipeline_Gateway_InvalidConnectionCredentials",
      "parameters": {},
      "details": [
        {
          "code""DM_ErrorDetailNameCode_UnderlyingErrorCode",
          "detail": {
            "type"1,
            "value""-2147467259"
          }
        },
        {
          "code""DM_ErrorDetailNameCode_UnderlyingErrorMessage",
          "detail": {
            "type"1,
            "value""The credentials provided for the SQL source are invalid. (Source at ad......-7s2tvmzlt6oevooga2lpcmwpwa.datawarehouse.pbidedicated.windows.net;TestLakehouse.)"
          }
        },
        {
          "code""DM_ErrorDetailNameCode_UnderlyingHResult",
          "detail": {
            "type"1,
            "value""-2147467259"
          }
        },
        {
          "code""Microsoft.Data.Mashup.CredentialError.DataSourceKind",
          "detail": {
            "type"1,
            "value""SQL"
          }
        },
        {
          "code""Microsoft.Data.Mashup.CredentialError.DataSourcePath",
          "detail": {
            "type"1,
            "value""ad......-7s2tvmzlt6oevooga2lpcmwpwa.datawarehouse.pbidedicated.windows.net;TestLakehouse"
          }
        },
        {
          "code""Microsoft.Data.Mashup.CredentialError.Reason",
          "detail": {
            "type"1,
            "value""AccessUnauthorized"
          }
        },
        {
          "code""Microsoft.Data.Mashup.MashupSecurityException.DataSources",
          "detail": {
            "type"1,
            "value""[{\"kind\":\"SQL\",\"path\":\"ad......-7s2tvmzlt6oevooga2lpcmwpwa.datawarehouse.pbidedicated.windows.net;TestLakehouse\"}]"
          }
        },
        {
          "code""Microsoft.Data.Mashup.MashupSecurityException.Reason",
          "detail": {
            "type"1,
            "value""AccessUnauthorized"
          }
        }
      ],
      "exceptionCulprit"1
    }
  }
}
 
This in my body for the REST API (patch datasources) :
{
  "credentialDetails": {
    "credentialType""OAuth2",
    "credentials""{\"credentialData\":[{\"name\":\"accessToken\",\"value\":\"eyJ0eXAiOi......\"}]}",
    "encryptedConnection""Encrypted",
    "encryptionAlgorithm""None",
    "privacyLevel""Private"
  }
}
 
To retrieve the token, I used this url :
https://login.microsoftonline.com/common/oauth2/authorize?display=&client_id={client_id}&redirect_ur...{redirect_uri}&resource=https%3A%2F%2Fdatabase.windows.net%2F&response_type=code&scope=.default%20openid&state={state}&prompt=select_account
 
My app in AAD has the API "Azure SQL Database" and "Azure Storage" authorization.
 
Any idea why this isn't working (again this works for Dataflows) ? Is my scope / resource not the correct one for Fabric?
 
Thanks for your help and guidance, let me know if you need more information !
 
2 REPLIES 2
Anonymous
Not applicable

Hi  @IAmStandard ,

 

According to your requirement description, it seems that you need to update credentials for SharePoint and other Power BI dataset datasources, according to my view of the permissions requirements for this corresponding rest API in the official documentation, it seems that it needs at least the Power BI side of the permission scope: Dataset.ReadWrite. .All, would it be convenient for you to add this to the corresponding application before trying it out?

Datasets - Update Datasources - REST API (Power BI Power BI REST APIs) | Microsoft Learn

 

Best Regards,

Liu Yang

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

Hi @Anonymous ,

 

Thanks for your reply. The API I use if actually this one. And it works very well for SharePoint and Dataflows, my only issue is with the SQL Endpoint of a Fabric Lakehouse.

I think I don't have the correct documentation to get the correct AccessToken for this specific datasource. Do you have any info on that ?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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