Hamer57's avatar
Hamer57
New Member
7 years ago
Status:
Done

Bad request (400)

We get an error in powershell with "invoke-RestMethod" on "https://api.powerbi.com/v1.0/myorg/admin/groups."

 

$groups = Invoke-RestMethod -Uri $urigroups –Headers $authHeader –Method GET –Verbose

VERBOSE: GET https://api.powerbi.com/v1.0/myorg/admin/groups with 0-byte payload

Invoke-RestMethod : The remote server returned an error: (400) Bad Request.

At line:2 char:11

+ $groups = Invoke-RestMethod -Uri $urigroups –Headers $authHeader –Method GET –Ve ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException

+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

On "https://api.powerbi.com/v1.0/myorg/admin/datasets" we do not receive an error:

VERBOSE: GET https://api.powerbi.com/v1.0/myorg/admin/datasets with 0-byte payload

VERBOSE: received -1-byte response of content type application/json; odata.metadata=minimal; odata.streaming=true

9 Comments

  • Hi Dale,

     

    Thanks.

    Still getting error 400 when using Invoke-RestMethod.

    What worked for me:

     

    Best Regards,

    Remko

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi Remko,

     

    Thanks for sharing. Update: the report No. : CRI 105642036.

    BTW, if you have a large number of App workspaces. The max number could be 5000.

     

    Best Regards,

    Dale

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi Hamer57 ,

     

    I got the responses from the Product Team. They will update the documentation. The $top parameter is mandatory for better performance. If you have more than 5000 App workspaces, you can get them by calling the API more than once.

     

    Best Regards,

    Dale

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

    This issue is still happening. Any news?

    {"error":{"code":"InvalidRequest","message":"This API expects $top query option to be provided."}}
     
    Is the Top mandatory? According to the documentation it should not be needed.