VMware Horizon Community
xyz20010
VMware Employee
VMware Employee

Problem when I'm calling Horzion View 8 Rest API

Hi everyone,

      I'm testing Horzion view server api (for version 8.0) using the postman.

      when I test the following API, something doesn't work, I don't know is it a bug or I do the wrong calling, who can help me?

      API:

           https://{{horizonserver}}/rest/inventory/v1/machines

            I used a filter to query by user_ids, the filter json string is :

           

{

"type":"Contains",

"name":"user_ids",

"value":[ "S-1-5-21-132563458-2059465199-3485338518-501", "S-1-5-21-132563458-2059465199-3485338518-500" ]

}

and I used a url encode tool to encode it:

%7B%0A%22type%22%3A%22Contains%22%2C%0A%22name%22%3A%22user_ids%22%2C%0A%22value%22%3A%5B%20%22S-1-5-21-132563458-2059465199-3485338518-501%22%2C%20%22S-1-5-21-132563458-2059465199-3485338518-500%22%20%5D%0A%7D

the final url is :

https://{{horizonserver}}/rest/inventory/v1/machines?filter=%7B%0A%22type%22%3A%22Contains%22%2C%0A%22name%22%3A%22user_ids%22%2C%0A%22value%22%3A%5B%20%22S-1-5-21-132563458-2059465199-3485338518-501%22%2C%20%22S-1-5-21-132563458-2059465199-3485338518-500%22%20%5D%0A%7D

but the result is []

if I use the following filter json string :

{

"type":"Contains",

"name":"user_ids",

"value":"S-1-5-21-132563458-2059465199-3485338518-501"

}

encode it: %7B%0A%22type%22%3A%22Contains%22%2C%0A%22name%22%3A%22user_ids%22%2C%0A%22value%22%3A%22S-1-5-21-132563458-2059465199-3485338518-501%22%0A%7D

final url:

https://{{horizonserver}}/rest/inventory/v1/machines?filter=%7B%0A%22type%22%3A%22Contains%22%2C%0A%22name%22%3A%22user_ids%22%2C%0A%22value%22%3A%22S-1-5-21-132563458-2059465199-3485338518-501%22%0A%7D

I can get the result.

I think that is a bug.   who would like to help me ? Thanks!

James Xie

Reply
0 Kudos
3 Replies
xyz20010
VMware Employee
VMware Employee

Hi  chrisdhalstead​ ,  thanks for your  your horizion view postman collection, it's useful. Would you like give me help with this problem?

Thanks!

James Xie

Reply
0 Kudos
chrisdhalstead
VMware Employee
VMware Employee

Thanks James - I will get this off to the engineers who built the API and will let you know what I hear back

Thanks

Chris

Chris Halstead
Senior Staff Architect, EUC Technical Marketing
chalstead@vmware.com
Twitter: @chrisdhalstead
Perttu
Enthusiast
Enthusiast

Just noticed that in H2303 the value in Contains filter has to be enclosed in a list and without it the query doesn't work. This broke our in-house code.

https://..fi/rest/inventory/v1/machines?filter={"filters":[{"name":"user_ids","value":"S-1-5-21-..-179528","type":"Contains"},{"name":"desktop_pool_id","value":"a7683903-6e1b-46c0-9b2c-2de54e19833a","type":"Equals"}],"type":"And"}

yields

{
"status": "BAD_REQUEST",
"timestamp": 1683903443075,
"errors": [{
"error_key": "common.bad.payload.error",
"error_message": "Bad payload error."
}]}

If I enclose the value in Contains filter in brackets [] it works

https://..fi/rest/inventory/v1/machines?filter={"filters":[{"name":"user_ids","value":["S-1-5-21-..-179528"],"type":"Contains"},{"name":"desktop_pool_id","value":"a7683903-6e1b-46c0-9b2c-2de54e19833a","type":"Equals"}],"type":"And"}

However Horizon Filter and Pagination guide states:

Following filter types are supported in Horizon Server REST APIs –

  • Contains’ - Single value field filter.

A bug maybe?

Reply
0 Kudos