Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Error using Invoke-PowerBIRestMethod using a service principal

Hello Community,

 

I followed the steps below to use the powershell Invoke-PowerBIRestMethod using a service principal but facing errors getting the details of the group or dataset.

I followed the below steps:

- Created a service principal in Azure AD

- Assigned permissons per screenshot below

- Able to login using service principal details using Connect-PowerBIServiceAccount successfully

- Added service principal as Admin to the Power BI workspace

- Enabled the setting "Allow service principals to use read-only power bi admins APIs" in the power bi admin portal

- Added the Service Principal to the correct AD Group

- Then tried to run Invoke-PowerBIRestMethod -Url 'groups' -Method Get

Then I get the error below:

Invoke-PowerBIRestMethod : One or more errors occurred.
+ Invoke-PowerBIRestMethod -Url 'https://app.powerbi.com/v1.0/myTenantId/groups' -Method Get
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod

Response status code does not indicate success: 500 (Internal Server Error).

Category : WriteError
Activity : Invoke-PowerBIRestMethod
Reason : AggregateException
TargetName : Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
TargetType : InvokePowerBIRestMethod

Response status code does not indicate success: 500 (Internal Server Error).
System.Net.Http
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod.<InvokeRestMethod>d__35.MoveNext()

 

- Am I missing additional permissions on the service principal?

- Do I need power bi enterprise admin rights?

- Any typos or stuff I have missed?

 

I checked the other posts on this topic before posting here but they did not help resolve my issue 🙂

Your help is appreciated!