Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
pontushaglund
Helper I
Helper I

401 error trying to fetch Power BI Activity Log

I'm trying to use the Power BI REST API to fetch Power BI Usage Reports using a service principal. When using PowerShell I can fetch the reports using a user/password that has MFA turned on. My customer wants to use a service principal rather than a AD user that has MFA turned off.

I first call to get a token:

pontushaglund_0-1603083392028.png

 

Using that token I call:

When calling this I get a 401 Unauthorized. 
 
The user must have administrator rights (such as Office 365 Global Administrator or Power BI Service Administrator) to call this API.
 
Is it therefore not possible to get the activity logs using a service principal?
4 REPLIES 4
VSmart
Frequent Visitor

Is This any solution I also try to get audit logs. Add my app to security group, give rights to this group but still get a 401 Unauthorized.

lbendlin
Super User
Super User

I assume your organization's IT team do not want to give these admin rights to a service principal login?

I now tried adding the service principal to the role Power BI Admin in the Azure portal. This did not help, still getting 401 error.

pontushaglund_0-1603168382889.png

 

This user is also part of a security group:

pontushaglund_1-1603168704251.png

I've also allowed access for this security group in the Power BI portal:

pontushaglund_2-1603168748371.png

 

Is it even possible? I've added the service principal in the Power BI Admin portal. Still 401. Am I missing something?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.