cancel
Showing results for 
Search instead for 
Did you mean: 
0

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

Status: Delivered
Comments
Community Support Team

Hi @Hamer57 ,

 

I have reported this issue to the Product Team. There could be a workaround for now. 

Add the $top parameter to the URL: https://api.powerbi.com/v1.0/myorg/admin/groups?$top=3000Bad-request-400

 

 

Best Regards,

Dale

Occasional Visitor

Hi Dale,

 

Thanks.

Still getting error 400 when using Invoke-RestMethod.

2019-02-19_10h19_53.png

What worked for me:

2019-02-19_10h22_30.png

 

Best Regards,

Remko

Community Support Team

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

Community Support Team
Status changed to: Accepted
 
Community Support Team

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

Community Support Team
Status changed to: Delivered
 
Occasional Visitor

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.