Forum Discussion

swapnil-saxena's avatar
swapnil-saxena
Frequent Visitor
2 years ago

REST API using MS Entra ID App

Hi,

 

I'm experimenting with triggering MS Fabric REST API using MS Entra ID App as suggested in below doc:

https://learn.microsoft.com/en-us/rest/api/fabric/articles/get-started/fabric-api-quickstart

 

I have created an Entra App and provided required required API and workspace level permissions.
Using Postman, I trigger the REST API endpoint for Get Item endpoint but I couldn't get the token for the mentioned scope: https://api.fabric.microsoft.com/Item.Read.All 

 

So, I tried with scope: "https://analysis.windows.net/powerbi/api/.default", which worked. I could get the initial token but when I tried the next step to get details for a particular Fabric item, I get below authentication error.

"The caller is not authenticated to access this resource"

 

I'm not sure if I'm using the right parameters. Can someone suggest the right parameters that I can use here?

 

Thanks.

18 Replies

    • swapnil-saxena's avatar
      swapnil-saxena
      Frequent Visitor

      Not yet. A few endpoints work from inside notebooks but I'd really like these to be working through external apps via SPNs. 

    • swapnil-saxena's avatar
      swapnil-saxena
      Frequent Visitor

      Thanks for the reply. I noticed about SPN support earlier, however, it just doesn't add up with what's mentioned in this doc:

      https://learn.microsoft.com/en-us/rest/api/fabric/articles/get-started/fabric-api-quickstart

      Isn't this contradictory to "SPN being unsupported" or am I misinterpreting this?

       

      I'm trying to trigger Get Item and Job Scheduler - Run On Demand Item Job endpoints but none work in addition to the ones that you mentioned. Getting

      "message""Unable to process the operation due to an error in the request"

       

       

    • swapnil-saxena's avatar
      swapnil-saxena
      Frequent Visitor

      Thanks. I was using the v2 url to get the token. I fixed it with the one that you suggested and I can get the token now. But it doesn't seem to work with any of the REST endpoints. Getting 

      "message""Unable to process the operation due to an error in the request"
       
      Can you also similarly show params for any endpoint that works for you? I'm particularly interested in these two: Get Item and Job Scheduler - Run On Demand Item Job
      • frithjof_v's avatar
        frithjof_v
        Community Champion

        I think you only need one header parameter, Authorization.

         

        If your token is 12345 then the value you enter in the Authorization header should be Bearer 12345.

         

        Thus, you need to add Bearer in front of the token.

         

        https://pbi-guy.com/2023/03/25/connect-with-power-bi-to-the-power-bi-rest-api-with-a-service-principal/

         

        That worked for me with the endpoints I mentioned

         

        You also need to make sure that you gave the app registration permissions to read the required scopes in the API permissions page in the App registration in Azure portal.

         

         

        I agree there seems to be some contradiction in the documentation regarding whether or not service principal is supported. In my experience, currently service principal authentication doesn't work for the Lakehouse endpoint, but it works for the endpoints I mentioned.

  • swapnil-saxena :   Hi Swapnil,  Just wanted to check in to see if there have been any updates regarding your ticket. I'm encountering the exact same issue where the returned token is generating an "Unable to process the operation due to an error in the request" message while trying to use the Shortcuts API . 

     

    Thanks,

    Anand

    • swapnil-saxena's avatar
      swapnil-saxena
      Frequent Visitor

      I haven't yet got a resolution on this. This is still being investigated.

  • ksurujon's avatar
    ksurujon
    Frequent Visitor

    Hi @swapnil-saxena 

    Have you got any solution by now?  or any response as for when it will be supported? specifically I am interested in Job Scheduler - Run On Demand Item Job

    Thank you