VMware {code} Community
kri-2
Hot Shot
Hot Shot
Jump to solution

using filters in the new vCenter 6.5 REST API (APIExplorer)

Hi,

I am just on trying my first steps with the new great REST API of vCenter 6.5.

One Task that often arises, is listing all Hosts of a given Cluster.
I first tried to accomplish this Task via the APIExplorer.

So first step I got a sessionid (token), no Problem. (rest/com/vmware/cis/session)
Second step I tried to list all Hosts of the vCenter, fine. All Hosts are returned in a nice json string. (rest/vcenter/host/)
But now I want to set a filter as documented. So I entered the name of an existing cluster in the textfield "filter.clusters"
And now I allways get an empty result, no matter what kind of Format I give the filter:
test_cluster
"test_cluster"
["test_cluster"] <- this should be correct, since it is expecting a Array of strings
{["test_cluster"]}

A Little python script confirms the problem - no data, when a filter is given.

Did anybody had yet the task to filter the result of a REST query?

Any ideas here?

Chris

1.PNG

2.PNG

0 Kudos
1 Solution

Accepted Solutions
kri-2
Hot Shot
Hot Shot
Jump to solution

Just got the solution:

The filter must not be the friendly name of the cluster, but the id of the cluster e.g. cluster-2 (which can be queried by using /vcenter/cluster).

View solution in original post

0 Kudos
2 Replies
kri-2
Hot Shot
Hot Shot
Jump to solution

Just got the solution:

The filter must not be the friendly name of the cluster, but the id of the cluster e.g. cluster-2 (which can be queried by using /vcenter/cluster).

0 Kudos
tganchev
VMware Employee
VMware Employee
Jump to solution

Hi kri-2,

Glad you're unblocked. You can post your REST API-related questions to the Cloud Suite SDK for REST forum. The current one is frequented mainly by people writing plugins for the vSphere Client.

-Tony

0 Kudos