Forum Discussion
Unauthorized 401 API powerbi admin activity events
- 1 year ago
Hi Anonymous ,
No, the GetActivityEvents API only supports retrieving one day of data per request.You cannot get multiple days in a single call.
As a Workaround to get more than one day of metrics, you need to call the API repeatedly, once per day, using different startDateTime and endDateTime values for each date.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly.
Thank you.
- Anonymous1 year ago
Hey VE I made a python script to loop over the api call to get all events for the past 30 days as you can make 200 api calls in an hour so I am following that process and ingesting my data into azure sql db! Thank you for your help!
Hi Anonymous ,
Thank you for reaching out to Microsoft Fabric Community.
It looks like you've set up most things correctly, but the 401 Unauthorized error usually comes down to one or two key missing steps.
Here’s a simple checklist to help you fix it:
1.Make sure your app has the AuditLog.Read.All permission (not just Tenant.Read.All).
2.When generating the token, you must request it for Microsoft Graph, not just Power BI(Use Graph API token scope)
3.Even if the service principal is added in Fabric Admin, the activity events API only works if it's a Power BI Admin (or Global Admin).
4.Audit data can take up to 24 hours to show up. So if you’re testing with very recent activity, it might return empty even if authorized correctly.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly.
Thank you.