azuremicrosoft-fabric

Getting error while calling Fabric REST API's


While testing Fabric API's with POSTMAN, For Get Call, getting below error

https://api.fabric.microsoft.com/v1/workspaces/****

Error:

"errorCode": "InsufficientPrivileges", "message": "The caller does not have sufficient permissions to access the requested resource",

For Update Git API-POST call, getting below error https://api.fabric.microsoft.com/v1/workspaces/****/git/updateFromGit

Error:

"errorCode": "PrincipalTypeNotSupported",
"message": "The operation is not supported for the principal type"

Service Principal enter image description here


Solution

  • The error "The caller does not have sufficient permissions to access the requested resource" usually occurs if the Microsoft Entra ID application does not have proper permissions or role to call the API.

    To resolve the error, you need to add Microsoft Entra ID application/Service Principal as Admin or contributor to the workspace:

    enter image description here

    Grant below API permission:

    enter image description here

    Generate access token:

    https://login.microsoftonline.com/TenantID/oauth2/v2.0/token
    
    client_id:
    client_secret: xxx
    scope: https://api.fabric.microsoft.com/.default
    grant_type: client_credentials
    

    enter image description here

    I am able to call the API successfully:

    GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}
    

    enter image description here

    Note that: The Update From Git API cannot be called using client credential flow. That is this API doesn't not support Service principal or managed identity. Refer this MsDoc

    Hence you are getting the error "PrincipalTypeNotSupported" as you are generating access token from client credential flow and calling the API.

    Hence to resolve the error, you need to switch to any user interactive flow and grant delegated API permission Workspace.GitUpdate.All to the Microsoft Entra ID application.