Forum Discussion

JoshT's avatar
JoshT
Advocate III
3 years ago
Solved

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/a...
  • JoshT's avatar
    3 years ago

    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!