Forum Discussion

munnas's avatar
munnas
Regular Visitor
1 year ago
Solved

Unable to trigger fabric data pipeline using REST API's

Hi, 

 

I have recently created, microsoft data fabric trail account with 60 day trail.

And under this trail account, I am trying to invoke microsoft data fabric data pipeline using Postman/from some external client.

 

Based on the docuementation(i.e. https://learn.microsoft.com/en-us/fabric/data-factory/pipeline-rest-api#obtain-an-authorization-token), I tried to optain the token with below curl:


curl --location 'https://login.microsoftonline.com/tanentId/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=myclientId' \
--data-urlencode 'client_secret=mysecret' \
--data-urlencode 'scope=https://api.fabric.microsoft.com/.default' \
--data-urlencode 'grant_type=client_credentials'


I get the token, but when i am using the same token to rigger the pipline using below curl. but i get 401 error with message "The caller is not authenticated to access this resource". please help how can i proceed.

 

curl --location --request POST 'https://api.fabric.microsoft.com/v1/workspaces/myworkspaceid/items/mypiplelineid/jobs/instances?jobType=Pipeline' \
--header 'Authorization: Bearer <token>' \
--data ''

 

Thanks.

8 Replies

  • munnas - The API that you use to trigger a Fabric Data Pipeline does not support Service Principals.  You have to use a named user account & password.  They will be bringing service pricipal support to more API's in the future.

     

    It does work with Username/Password as we are able to do that within our Company.   It will eventually work in Power Automate but since the API does not return a response the HTTP Post with Azure Entra (preauthorized) does not function properly.

     

    There is another thread in the community that goes into more detail.  It's fairly recent.

     

    Jeremy

  • Evaluate your token at jwt.io  most likely you have misconfigured the application scope.  Don't use delegated permissions.

    • lbendlin's avatar
      lbendlin
      Super User
      Since microsoft fabric was not available, I added application permissions for the Power BI service instead.

      I would call this the "money tree approach". You may want to investigate if there are Fabric specific permissions, either already implemented or planned.

  • Did you add the service principal to access the workspace where the data pipeline is in with sufficient permissions? You do not need any application permissions as shown in the screenshot. Also make sure that your service principal is able to run REST APIs. This can be set in the Power BI (Fabric) admin settings.