Forum Discussion
Unauthorized 401 when accessing Power BI Admin API
- Anonymous2 years ago
Hi novirae ,
According to the error message, 401 Unauthorized error usually indicates a problem with authentication or permissions, you can check if the tenant settings are turned on in the following official documentation:
Admin API admin settings - Microsoft Fabric | Microsoft Learn
This is the related document, you can view this content:
Solved: Power Bi REST API - 401 Authorization error when u... - Microsoft Fabric Community
Troubleshoot Power BI REST APIs - Power BI | Microsoft Learn
Solved: Power Bi REST API - 401 Authorization error when u... - Microsoft Fabric Community
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.
Hey SethParker,
No. We weren't able to get past it at least in a way I'd love to. After some later testing, discussions, posting on different sites I came to a conclusion that this is indeed a bug / not implemented feature for multiple reasons (maybe including security?)
What seemed to be working was generating REST API token using grant_type = password instead of client_credentials, but that forces you to specify Entra ID username/password (and that username ideally wouldn't have MFA enabled, which is a very strict no-go for us).
We ended up with named (per user) administrative-like account that has MFA enabled and we use that in Powershell script (using Connect-PowerBIServiceAccount) to assign access to workspaces.
After that we use the App Registration to do administrative tasks like removing old reports / archiving them to Blob Storage etc. that can be done per workspace level
Thank you for your response! I agree that this seems to be a bug. We are trying to query Activity History (and a couple of other tables) from the Admin API, so I don't know of another way to get to that data with an App Registration. A non-MFA user with access to the Admin API is a non-starter for us as well. Thanks again!
- novirae1 year agoFrequent Visitor
You shouldn't have any issue querying read only APIs (like activity history, list of workspaces / datasets / reports) etc - we have entire monitoring solution based on that data that are getting retrieved by service principal/app registration. The only thing we weren't able to get working is using POST requests (like add access to workspace) via App Registration - rest works perfectly fine