5.5

Table Of Contents
Encoding Filter Expressions
When you are comparing a key with a literal value that includes characters that might be subject to
interpretation when used in a URL (often termed unsafe characters), the value must be encoded as described
in RFC3986 (pct-encoded). For example, to create a filter expression to match a hostName property whose
value is 12&345, encode the value as shown here:
filter=hostName==12%26345
When a filter expression includes metadata, you must encode both the key and the value this way. In
addition, if you specify filterEncoded=true as part of a query that includes metadata, you must encode the
% symbol as %25. For example, this query, which includes metadata would require this sort of additional
encoding if you specified filterEncoded=true.
https://vcloud.example.com/api/query?
type=organization&format=records
&fields=metadata:rank,metadata@SYSTEM:expiry
&filter=metadata%40SYSTEM%3Aexpiry%3Dlt%3DDATETIME%3ADATETIME
%253A2012-05-01T00%253A00%253A00.000-04%253A00DATETIME
%253A2012-05-01T00%253A00%253A00.000-04%253A00&filterEncoded=true
If you did not specify filterEncoded=true, you would not need the additional encoding.
https://vcloud.example.com/api/query?
type=organization&format=records
&fields=metadata:rank,metadata@SYSTEM:expiry
&filter=metadata@SYSTEM:expiry=lt=DATETIME:DATETIME%3A2012-05-01T00%3A00%3A00.000-04%3A00
Grouping Filter Subexpressions
Group filter subexpressions with parentheses. Separate grouped subexpressions with a semicolon (no
spaces).
(attribute1==value1;attribute2!=value2);(attribute3==value3;attribute4!=value4)...
For example:
https://vcloud.example.com/api/query?
type=providerVdcResourcePoolRelation&format=records&filter=(numberOfVMs!=0;isPrimary==true)
Attribute Names and Values
Several parameters and all filter expressions require you to specify an attribute name. You can use the
schema reference to find the attribute names included in a particular result set.
1 In the vCloud API Schema Reference, select All Queries.
2 Type the query name (or any part of it) in the Quick Index window, then open the query reference
page.
3 On the query reference page, click the link in the Record Result section to open a page that shows the
name, type, description, and other information for each attribute returned by the query. Attributes that
can be used in a filter expression have a YES in the FILTER column. Attributes that can be used with
sortAsc or sortDesc have a YES in the SORT column.
vCloud API Programming Guide
302 VMware, Inc.