Query records and operators
GET request format, query parameters, response headers and the JSON query operators of the REST API, with a request and response for each.
A GET request reads one record by its ID, or a page of records that match a query. This reference lists the URL forms, parameters, response headers and query operators for developers who call the REST API.
Request format
Every request goes to /v1/ on your instance, followed by the table name and, for one record, the record ID.
| Request | URL | Response |
|---|---|---|
| One record | https://<instance>.servicely.ai/v1/<Table>/<id> |
data holds one object |
| A list of records | https://<instance>.servicely.ai/v1/<Table> |
data holds an array of objects |
The request runs as the authenticated user. Table permissions, field permissions and record restrictions apply, so a field the user cannot read is left out of the response. Empty fields are left out unless you set include_empty_fields=true.
Responses are pretty-printed JSON. Send an X-NO-JSON_FORMATTING header with any value to get compact JSON.
| Status | When |
|---|---|
| 200 | Records were found |
| 401 | The request is not authenticated |
| 403 | The user cannot read records the query needs |
| 404 | The record ID does not exist, or a list query matched no records |
A list query that matches nothing returns 404 with an empty data array. Treat it as an empty result, not an error.
Query parameters
Parameters are case-sensitive. A parameter whose name starts with a capital letter is a field filter: WorkflowStatus=new returns records whose WorkflowStatus equals new. Several field filters must all match.
| Parameter | Takes | Description |
|---|---|---|
fields |
Field names, comma separated | Returns only these fields. Add displayValue to include the record’s display value. |
exclude |
Field names, comma separated | Leaves these fields out of the response. |
displayValues |
Field names, comma separated | Returns each named field as an object with value and displayValue. |
availableValues |
Field names, comma separated | With displayValues, also returns the field’s choice values in availableValues. |
relations |
Relation paths, comma separated | Returns fields of related records, for example AssignmentGroup.Name or Requestor.Manager.Name. |
inlineRelations |
true or false |
true, the default, nests related records in the field. false returns their IDs in the field and the records in a top-level relations object keyed by ID. |
include_empty_fields |
true or false |
Returns fields that have no value. Default false. |
query |
A JSON query | Filters with conjunctions and operators, described under Query operators below. |
order |
Field names, comma separated | Sorts ascending by each field in turn. |
order_desc |
Field names, comma separated | Sorts descending by each field in turn. |
page |
A number from 1 | The page to return. Pages below 1 return page 1. |
page_size |
A number | Records per page. |
first_result |
A number from 0 | The zero-based position of the first record to return. Use it instead of page. |
max_results |
A number | The same as page_size. |
file_name |
A file name | Adds a Content-Disposition: attachment header so a browser saves the response under this name. |
requestID |
Any text | Echoed back in the X-Response-To header. |
The page size defaults to the value of the application property system.rest.api.page.size.hard.limit, which ships as 200. A larger page_size is reduced to that limit.
Response headers
| Header | Takes | Description |
|---|---|---|
X-Page |
A number | The page returned. |
X-Page-Size |
A number | The page size used. |
X-Result-Count |
A number | Records in this response. |
X-Total-Result-Count |
A number | Records that match the query across all pages. |
X-Result-More |
true or false |
true when more pages follow. |
X-Rate-Limit-Cost |
A number | Records and related records the response encoded. Asking for fewer relations lowers it. |
X-Response-Time |
Milliseconds | Time the server took to answer. |
X-Response-To |
Text | The requestID you sent. |
To read every record, request page 1, then the next page while X-Result-More is true.
Query operators
The query parameter takes a JSON object. Its key is a conjunction and its value is an array of criteria. A criterion is either a field test or another conjunction, so conjunctions nest.
{
"and": [
{ "fieldName": "Priority", "operator": "in", "value": ["1", "2"] },
{ "fieldName": "Closed", "operator": "=", "value": false }
]
}
A fieldName can follow relations with dots, for example Manager.Email. URL-encode the JSON, or let your HTTP client do it.
Conjunctions
Conjunction keys are not case-sensitive.
| Conjunction | Takes | Description |
|---|---|---|
and |
An array of criteria | Every criterion must match. |
or |
An array of criteria | At least one criterion must match. |
nor |
An array of criteria | No criterion may match. |
Field operators
The Takes column is the operator’s arity: how many values value holds.
| Operator | Takes | Description |
|---|---|---|
= |
One value | Equals the value. |
!= |
One value | Does not equal the value. Records where the field is empty do not match. |
contains |
One value | The text contains the value. like does the same. |
doesnotcontain |
One value | The text does not contain the value. notlike does the same. |
startswith |
One value | The text starts with the value. |
endswith |
One value | The text ends with the value. |
donotstartwith |
One value | The text does not start with the value. |
donotendwith |
One value | The text does not end with the value. |
isempty |
None | The field has no value. |
isnotempty |
None | The field has a value. |
in |
A list | Equals one of the values. |
notIn |
A list | Equals none of the values. |
< |
One value | Less than the value. |
> |
One value | Greater than the value. |
<= |
One value | Less than or equal to the value. |
>= |
One value | Greater than or equal to the value. |
between |
Two values | Between the two values in the array. |
fts |
One value | Matches the value with a full-text search. |
>> |
One value | An IP network field contains the address or network. |
>>= |
One value | An IP network field contains or equals the address or network. |
<< |
One value | An IP address field lies within the network. |
<<= |
One value | An IP address field lies within or equals the network. |
orderby |
None | Sorts ascending by the field. |
orderbydesc |
None | Sorts descending by the field. |
Operators are not case-sensitive. The parser also accepts the constant names, such as EQUAL, NOT_IN and IS_EMPTY, and the abbreviations eq, ne, gt, gte, lt and lte.
Examples
Each example shows the request line and the response. Headers that do not matter to the example are left out.
One record
Request
GET /v1/Incident/00000000000000000000000000000001?fields=id,WorkflowStatus,ShortDescription,AssignmentGroup
Response
{
"data": {
"AssignmentGroup": "00000000000000000000000000000010",
"ShortDescription": "Example incident",
"WorkflowStatus": "work_in_progress",
"id": "00000000000000000000000000000001"
}
}
Field filter and sort
Request
GET /v1/Incident?WorkflowStatus=new&fields=id,Urgency&order_desc=Urgency
Response
X-Page: 1
X-Page-Size: 200
X-Result-Count: 2
X-Result-More: false
X-Total-Result-Count: 2
{
"data": [
{ "Urgency": "medium", "id": "00000000000000000000000000000011" },
{ "Urgency": "high", "id": "00000000000000000000000000000001" }
]
}
Display values
Request
GET /v1/Incident?fields=Number&displayValues=Classification,AssignmentGroup
Response
{
"data": [
{
"AssignmentGroup": {
"displayValue": "Support",
"value": "00000000000000000000000000000010"
},
"Classification": {
"displayValue": "Other",
"value": "00000000000000000000000000000100"
},
"Number": "<number>"
}
]
}
Related and nested records
Request
GET /v1/Incident?fields=id,ShortDescription&relations=Requestor.Name,Requestor.Manager.Name
Response
{
"data": [
{
"Requestor": {
"Manager": {
"Name": "<manager name>",
"id": "00000000000000000000000000000101"
},
"Name": "<requester name>",
"id": "00000000000000000000000000000110"
},
"ShortDescription": "Example incident",
"id": "00000000000000000000000000000011"
}
]
}
Paging
This request returns the fifth page of users, two at a time.
Request
GET /v1/User?fields=id,Name&page_size=2&page=5
Response
X-Page: 5
X-Page-Size: 2
X-Result-Count: 2
X-Result-More: true
X-Total-Result-Count: 14
{
"data": [
{ "Name": "<user name>", "id": "00000000000000000000000000000111" },
{ "Name": "<user name>", "id": "00000000000000000000000001000000" }
]
}
JSON query through a relation
This query finds active users whose manager has a given email address. The JSON is shown before URL encoding.
Request
GET /v1/User?fields=Email,Active&query={"and":[{"fieldName":"Active","operator":"=","value":true},{"fieldName":"Manager.Email","operator":"=","value":"manager@example.com"}]}
Response
{
"data": [
{
"Active": true,
"Email": "user@example.com"
}
]
}
To build a query, set the filter on a list in the product and copy it as JSON. Configure a list layout describes the copy options.