Filtering

Version 24.1.8910


Filtering

Version 24.1.8910


The REST API supports OData filtering to retrieve specific sets of resources. To apply OData filters, you simply set them as the $filter query parameter in the target URL.

You can use the following logical operators to build OData filters:

  • eq Equal to
  • ne Not equal to
  • gt Greater than
  • ge Greater than or equal to
  • lt Less than
  • le Less than or equal to
  • not Negation

For example, the following API request uses gt to retrieve History metadata for all jobs after January 1, 2024:

GET http://localhost:8181/sync/api.rsc/history?$filter=runstartdategt 2024-01-01

You can also combine OData filters with the and and or keywords. For example, the following API request retrieves history metadata for all jobs with specific connector after August 26, 2019:

http://localhost:8181/sync/api.rsc/history?$filter=runstartdate gt 2019-08-26 and connectorid eq myConnector

The REST API also supports the following functions inside of an OData filter:

  • startswith(property, ‘value’): Resources are returned only when the specified property begins with the specified value.

  • endswith(property, ‘value’): Resources are returned only when the specified property ends with the specified value.

  • contains(property, ‘value’): Resources are returned only when the specified property contains the specified value.

For example, the following API request retrieves Job History details for jobs that failed:

GET http://localhost:8181/sync/api.rsc/history?$filter=contains(details,''failed')

Selecting Specific Fields

In addition to the $filter query parameter, you can set the $select query parameter to limit the specific fields that are returned in the response. You should set this parameter to a comma-delimited list of the properties that you want to retrieve. For example, the following API request retrieves the name and workspace of each configured connector, but none of the other configuration details of these connectors:

GET http://MyDomain.com:8001/api.rsc/connectors?$select=connectorid,workspace

Ordering Results

In addition to $filter and $select, you can set the $orderby query parameter to sort results into a specific order. This parameter is specified with the following syntax:

$orderby=ColumnName SortDirection

In this syntax, ColumnName is the column to use for sorting (for example, filename, connectorId, timestamp) and SortDirection is either asc (for ascending order) or desc (for descending order).

For example, the following API request retrieves Job History details for all jobs that failed. Then, the request orders them by when the job started, in descending order.

GET http://localhost:8181/sync/api.rsc/history?$filter=contains(details,'ERROR')&$orderby=runstartdate desc

You can specify multiple ordering conditions by setting the $orderby parameter to a comma-delimited list. Conditions earlier in the list take precedence over conditions later in the list. For example, the following API request retrieves the same data as the previous request, but the request first groups the failed jobs based on which instance of Sync ran the job.

GET http://localhost:8181/sync/api.rsc/history?$filter=contains(details,'ERROR')&$orderby=instanceid asc, runstartdate desc