Register an App to access Power BI Rest API (Get Activity Events)
In order to check the usage of Power BI reports, we can download the Audit log data thru API.
The official documentation: Admin — Get Activity Events — REST API (Power BI Power BI REST APIs) | Microsoft Learn
I am not sure why Microsoft make the document so difficult to understand. You can ignore that and read my summary below.
Register an App (Service Principal) to access Admin API
- Sign into the MS Entra Admin Center.
- Select App registration > New registration
- Input the name and other information of the new App, leave the permission blank.
Create a security group for Admin API access
- Create a security group (require Global admin permission)
- Add the Service Principal you created in previous step into this group
- (require Fabric admin permission) Goto Power BI Admin portal (https://app.powerbi.com/admin-portal/tenantSettings), under Admin Settings > Admin API settings > Service principals can access read-only admin APIs. Change to “Enable” and add the security group.

Common Error
Get 401 error without error message.
According to official document: When running under service principal authentication, an app must not have any admin-consent required permissions for Power BI set on it in the Azure portal.
It means you either the global admin, or you should not have any permission. To fix it, goto App Registration > API Permissions.
If all you need is getting the event log, then remove ALL permission that have “Admin consent required=Yes”.
Expected literal type token but found token / Your code is passing continuationToken without quotation mark
Use use the continuationUri instead of continuationToken in your POST request. The continuationUri contain entire Uri which save you the trouble to build your string with continuationToken.
Get 403 error: “API is not accessible for application”
Double check the “Create a security group for Admin API access” section above.
404 error
404 means file not find. It may means your App is trying to access a workspace that don’t have permission.
Goto Power BI portal (https://app.powerbi.com/), click on WorkSpaces, click the “…” at the right of target workspace, click on “Workspace access”. Add your security group with Admin permission here.
