Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi Community , i 'm looking for getting power bi usage data for more than 3 months , i have purview account and azure app as well and azure app have permissions as well , but when i run notebook using power bi rest api's then i recieve response of 401 , i have given all necessary permissions to Azure App.
Solved! Go to Solution.
Hi @zainqazi96 ,
Here’s a concise checklist for your 401 error with Power BI API:
Permissions: Ensure your Azure app has API permissions (e.g., AuditLog.Read.All, Report.Read.All), and that admin consent is granted.
Token Scope: Use scope: https://analysis.windows.net/powerbi/api/.default, Pass token as Authorization: Bearer <token>
Admin Role: Some endpoints need your account to be a Power BI Service Admin.
Service Principal Support: Not all APIs work with service principal; try user context if needed.
Token Validity: Ensure token is fresh and for the correct tenant.
Hi @zainqazi96 ,
Thank you for reaching out to the Microsoft Community Forum.
Hi @MasonMA , @rohit1991 , @aj1973 , Thank you for your prompt responses.
Hi @zainqazi96 , If @MasonMA , @rohit1991 , @aj1973 , responses has resolved your query, please accept their response as " Accept as Solution" . If not, Please let us know if you have any further queries.
Regards,
Dinesh
Hi @zainqazi96
You're encountering a 401 Unauthorized error when attempting to access Power BI usage data using the Power BI REST APIs through a notebook, even though you've correctly set up your Azure app registration, granted permissions, and have a Purview account. This issue typically points to an authentication or permission misconfiguration, even if everything seems correctly assigned. First, ensure your Azure AD app has Power BI Service API permissions (like Tenant.Read.All, Report.Read.All, Dataset.Read.All, and AuditLog.Read.All if using activity logs), and that these are granted admin consent in Azure. If you're accessing activity log data for usage over 90 days, note that it comes from the Microsoft 365 Audit Logs, not directly from Power BI APIs. These logs require your Azure app to authenticate against the Microsoft Graph or Office 365 Management APIs, not just Power BI's REST API, and you must ensure that Audit logging is enabled in Microsoft Purview. If using delegated auth, confirm the user is a Power BI admin or has the required roles. If you're using client credentials (app-only), make sure the app is added to a security group that's assigned admin roles in the Power BI admin portal. Also verify the token acquisition step in your notebook—if the token isn’t scoped correctly for the API you're calling (e.g., wrong resource URL), the 401 error will occur. Use tools like Postman to test the same token against the API to confirm if it’s a token or permission scope issue.
hi @Poojara_D12 thanks for your response , apparantly we raised ticket to Microsoft and we have to create an new azure app for this purpose and gave all the adequete rights as per microsoft , now we are able to hit the API but we havent started getting data for over 90 days yet , but somehow we will figure it out , Thankyou so much for your guidance
Hi @zainqazi96 ,
Thank you for reaching out to the Microsoft Community Forum.
Hi @MasonMA , @rohit1991 , @aj1973 , Thank you for your prompt responses.
Hi @zainqazi96 , If @MasonMA , @rohit1991 , @aj1973 , responses has resolved your query, please accept their response as " Accept as Solution" . If not, Please let us know if you have any further queries.
Regards,
Dinesh
Hi @zainqazi96 ,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.
Regards,
Dinesh
Hi @zainqazi96
You can't fetch for data beyond last 90 days of Power BI activities. You need to start building a report like this
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
Hi @zainqazi96 ,
Here’s a concise checklist for your 401 error with Power BI API:
Permissions: Ensure your Azure app has API permissions (e.g., AuditLog.Read.All, Report.Read.All), and that admin consent is granted.
Token Scope: Use scope: https://analysis.windows.net/powerbi/api/.default, Pass token as Authorization: Bearer <token>
Admin Role: Some endpoints need your account to be a Power BI Service Admin.
Service Principal Support: Not all APIs work with service principal; try user context if needed.
Token Validity: Ensure token is fresh and for the correct tenant.
Hi there, i answered a similar post some days ago. The solution would be either have your IT admin enable Power BI Audit Logs and create one semantic model for you to query or use REST API following the instructions posted on Github.
You can refer to this post with below link.
https://community.fabric.microsoft.com/t5/Service/Usage-Reports/m-p/4767584
Hope it helps:)