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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
aaldo_666
Helper I
Helper I

Service Principal Rest Api Permissions

Hi I want to use Rest Api to get Activity events for last day. I have registered an app + AAD Group. Add group to API permisions in admin portal and set up permissions for the app registration like this:

 

aaldo_666_0-1674811097983.png

Tested in Powershell.

But still all I can do is list of workspaces where AAD Group is admin.

 

$rest = Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups" -Method Get | ConvertFrom-Json

 

I even cannot list reports inside one of those workspaces.

 

$rest = Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/reports/XXXXXXXXXXXXXXXXXXXXXXXXX" -Method Get | ConvertFrom-Json

 

In powershell version I get error Operation returned an invalid status code 'Forbidden'

My goal is to run this code in Data Factory to store it in sql server

 

Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/admin/activityevents?StartDateTime='2022-09-23T08%3A55%3A00.000Z'&EndDateTime='2022-09-23T10%3A55%3A00.000Z'"

 

Any advise what Im doing wrong?
Thanks.

1 REPLY 1
NandanHegde
Super User
Super User

Can you please confirm on the below aspect :

 

When running under service prinicipal authentication, an app must not have any admin-consent required premissions for Power BI set on it in the Azure portal.

 

 

https://learn.microsoft.com/en-us/rest/api/power-bi/admin/get-activity-events




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.