Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

"Groups UpdateGroupAsAdmin" API throws 401 Unauthorized error

I'm using https://learn.microsoft.com/en-us/rest/api/power-bi/admin/groups-update-group-as-admin API to update description of the workspace.

Workspace access is configured: service principle, which I use to authenticate API, is set as Admin for my workspace (also as described in this thread https://community.fabric.microsoft.com/t5/Developer/Unable-to-patch-reportgroup-name-with-a-service-principal/m-p/2912492#M39793).

 

But when I run "Groups UpdateGroupAsAdmin" request either from my C# code or from Postman, I receive 401 Unauthorized error.

 

Are the needed some specific rights to be set for service principle to execute this PATCH query?

 

Thank you very much in advance.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

     

    Please also check in the admin portal->tenant setting that the service principal setting related to rest API using is also enable for your service principal or for the whole organization.

    And also make sure all the permissions related to workspace is added for the serivice principal stands for the AAD application

    Grant tenant-wide admin consent to an application - Microsoft Entra | 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.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you v-yangliu-msft for the answer.

      Yes, of course I have enabled API usage for the service principle (otherwise I could not use API at all).

      Regarding Admin consent - I believe that it is not needed while using service principles, is it? For example, if you check description of this API https://learn.microsoft.com/en-us/rest/api/power-bi/admin/groups-get-group-users-as-admin, then it is said that in case when service principle is used, there must be no admin consents granted. So I believe that this is the case also for this UpdateGroupAsAdmin.