Advanced query features of the REST API

This article describes advanced concepts for querying resource data in Autotask by making GET and POST requests to the REST API.

We recommend reading this article after you have familiarized yourself with the key principles discussed in our Introduction to REST API calls article. For basic query syntax, refer to Making basic query calls to the REST API.

To help you learn how to construct requests to the Autotask REST API, Datto provides a customizable REST API request collection for use with Postman. For more information, refer to Sample requests.

Overview

The Autotask REST API features advanced call syntaxes that enable users to specify certain fields to return, obtain record counts, and paginate results. Select a topic to learn more.

NOTE  You can refer to the Online Help to find root and child access URLs of the entity you wish to query. Refer to Finding resource and child access URLs of REST API entities for more information.

BEFORE YOU BEGIN  Examples in this article may use the webservices[n].autotask.net placeholder. In such instances, substitute [n] for the zone of your user, as described in Autotask API zones and WSDL versionsFind your zone's API URL for the REST API or Autotask API zones and WSDL versionsFind your zone's WSDL file URL for SOAP API version 1.6.

Index


Specifying fields to return

By using the IncludeFields operator with GET or POST, you can customize your search results to return specified fields only. This operator works in conjunction with a comma-separated list of the field names included in a filter expression. You can include any object fields that the entity contains, including user-defined fields (UDFs). Click each description's name to view demonstration code and an explanation of the operator shown.

Obtaining a record count

You can use a GET or POST query to obtain a count of the number records for a specified filter expression. Click each description's name to view demonstration code and an explanation of the operator shown.

Specifying the maximum records to return

You can include a MaxRecords value with your request to specify the maximum number of records you'd like the API to return. The valid range of values for MaxRecords is 1 to 500. Click each description's name to view demonstration code and an explanation of the operator shown.

NOTE  If you specify and then change the MaxRecords value provided in the GET request body when using a previous or next page URL, the API will ignore that value, and the value you supplied for the original query will persist.

Paginating results

You can make use of the pagination URLs provided by a query response to view the next set or previous set of results.

IMPORTANT  Do not change the query method, the MaxRecords or IncludeFields values, or any filter criteria while using paging URLs. Unexpected results may occur. The prevPageUrl and nextPageUrl are based on the initial query. You should only provide the original filter when calling them.

Additional resources