Querying - Vivantio/apisamples GitHub Wiki
Each of the 'object' endpoints - Article, Asset, Caller, Client, Location, Ticket - provides a Select method which can be used to query data in that area. The query format used is specific to Vivantio and can take a while to get used to. We're hoping to introduce support for other querying methods - such as OData - in future versions of Vivantio. For now though, you need to pass in a valid Query object to use this method. The examples shown below are formatted using JSON, but the same basic structure is used if you're using XML.
A basic query object for use with the Select methods looks like:
{
Query :
{
Mode : "MatchAll",
Items : [
{
FieldName : "RecordTypeId",
Op : "Equals",
Value : 11
}
]
}
}
Where:
- Query marks the start of the 'Query' object
- Mode is one of:
- MatchAll
- MatchAny
- MatchNone
- Items is a collection of QueryItem objects, where each QueryItem consists of:
- FieldName - the name of the field to match
- Op - the operator to use, one of:
- Equals
- DoesNotEqual
- GreaterThan
- GreaterThanOrEqualTo
- LessThan
- LessThanOrEqualTo
- Like
- Value - the value to match
For more complicated queries, you can 'nest' one query inside another, e.g.:
{
Query :
{
Mode : 'MatchAll',
Items : [
{
FieldName : 'RecordTypeId',
Op : 'Equals',
Value : '10'
},
{
Mode : 'MatchAny',
Items : [
{
FieldName : 'CategoryId',
Op : 'Equals',
Value : 240
},
{
FieldName : 'CategoryId',
Op : 'Equals',
Value : 241
}
]
}
]
}
}