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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
JoshT
Advocate III
Advocate III

Status code 400 (bad request) on some Admin API calls

I've been getting a bad request calls to two of the admin APIs, GetGroupsAsAdmin and GetAppsAsAdmin, despite making calls in line with what the documentation (https://learn.microsoft.com/en-us/rest/api/power-bi/admin/groups-get-groups-as-admin) says.

 

I can make calls successfully to other admin APIs (e.g. dataflows and datasets). The difference with these two seems to be that they both have mandatory $top parameters, but I get the error whether or not I supply this parameter.

 

 

Connect-PowerBIServiceAccount
Invoke-PowerBIRestMethod -Method Get -Url "https://api.powerbi.com/v1.0/myorg/admin/groups?$top=10"
$Error[$Error.Count - 1].Exception.InnerException

 

JoshT_0-1668685418845.png

 

I've connected both as a tenant admin and as a service principal with the admin scope allowed and not had success with either. Are these APIs broken or am I doing something wrong?

1 ACCEPTED SOLUTION
JoshT
Advocate III
Advocate III

Using fiddler, found out that $top parameter wasn't being sent - the dollar sign required for the parameter name meant PowerShell was pulling in a session variable that didn't exist (so the uri would have been "https://api.powerbi.com/v1.0/myorg/admin/groups?=10" ).

 

The correct syntax is as below:

 

Invoke-PowerBIRestMethod -Method Get -Url "https://api.powerbi.com/v1.0/myorg/admin/groups?`$top=10"

 

I guess that's the problem with using the PowerShell ISE, string and variable are highlighted in only slightly different shades of brown!

View solution in original post

3 REPLIES 3
JoshT
Advocate III
Advocate III

Using fiddler, found out that $top parameter wasn't being sent - the dollar sign required for the parameter name meant PowerShell was pulling in a session variable that didn't exist (so the uri would have been "https://api.powerbi.com/v1.0/myorg/admin/groups?=10" ).

 

The correct syntax is as below:

 

Invoke-PowerBIRestMethod -Method Get -Url "https://api.powerbi.com/v1.0/myorg/admin/groups?`$top=10"

 

I guess that's the problem with using the PowerShell ISE, string and variable are highlighted in only slightly different shades of brown!

Habitat
Regular Visitor

Hi @JoshT 

 

Check this:

Permissions

  • The user must have administrator rights (such as Office 365 Global Administrator or Power BI Service Administrator) or authenticate using a service principal.
  • Delegated permissions are supported.

Required Scope

Tenant.Read.All or Tenant.ReadWrite.All

Yes, sorry, by tenant admin I meant Power BI service admin, and the service principal I'm using as an alternative has the necessary scope - as I said, other admin APIs work fine, it's just the groups and apps ones that don't work under any circumstances, with any of the parameters specified as per documentation.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.