Forum Discussion
Service Principal Admin API
Hello All,
Has anyone tried out the new feature "Service Principal with Admin API access" ? https://docs.microsoft.com/en-us/power-bi/admin/read-only-apis-service-principal-authentication
I have followed the steps as per the article but i get the error message
The remote server returned an error: (401) Unauthorized.
i suspect that the issue is related to this step [which is not clear to me]
Select Add Members. Note: Make sure the app you use does not have any Power BI admin roles set on it in Azure portal. To check this:
Can someone explain what permissions the service principal should have ? FYI we tried to use the service principal i while back to automate data collection via Power BI REST API's and currently these are the permissions assigned to the service principal
9 Replies
- v-kkf-msftCommunity Support
Hi Anonymous ,
Based on my understanding, I think this is more likely to be related to the authentication access token. REST API needs authentication, did you send authentication credentials along with your request?
To get the token, please refer to Get an authentication access token .
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
WinnizIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Hello,
Yes, i am passing/using the authentication token when i execute the REST API.
When i execute the non-admin API like this request "
https://api.powerbi.com/v1.0/myorg/groups" i get results
When i execute the admin API like this request "
https://api.powerbi.com/v1.0/myorg/admin/groups?%24top=5000" i get the error message
The remote server returned an error: (401) Unauthorized.
Do you need any other information ?
Thanks for your help!
- v-kkf-msftCommunity Support
Hi Anonymous ,
The permissions required by these two APIs are different. When you execute Admin - Groups GetGroupsAsAdmin API, you must have administrator rights (such as Office 365 Global Administrator or Power BI Service Administrator) to call this API or authenticate via service principal.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
WinnizIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- pvuppalaHelper V
Hi there, I found this post looking to use Service Principal to run Admin API. I get the same 401 (Unauthorized) error.
when I try to call this
$headers = Get-PowerBIAccessToken Invoke-RestMethod -Headers $headers -Uri 'https://api.powerbi.com/v1.0/myorg/admin/capacities/AssignWorkspaces' -body $bodyStr -Method PostPlease confirm if Service PRincipal is intended to those read-only APIs ?