Forum Discussion

aaldo_666's avatar
aaldo_666
Helper I
3 years ago

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:

 

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.