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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-jiascu-msft
Employee

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

Hamer57
New Member

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

v-jiascu-msft
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
Employee
Status changed to: Accepted
 
v-jiascu-msft
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

v-jiascu-msft
Employee
Status changed to: Delivered
 
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.
ksabi
Advocate II

Hi, 

 

I'm getting the same error with PowerShell: 

https://api.powerbi.com/v1.0/myorg/admin/groups?$top=100

 

Do you have any news? 

 

Best Regards,

ksabi

 

ksabi
Advocate II

@Anonymous  If you still have the issue, 

 

I tried this url and it works for me.  https://api.powerbi.com/v1.0/myorg/admin/groups?%24top=100 

 

It appears that the $ is not read correctly. 

 

Best Regards, 

ksabi