Many times you will need to filter and sort your GETs. For example, you might want all the invoices belonging to a specific account ordered by date. To do this you need to use the search request header. Search requests allow you to filter and sort the returned data on one or more properties of the object. The basic forumula for the search request is:
A filter array that can be conceptualized as where clauses.
A condition which logically joins the filter array with the orderby array using a logical AND
An orderBy array that sorts the returned data
A filter combines a property, an operator, and a value. Since the filter is an array, elements can be combined using the condition property with a value of 'and'.
Here is an example of a basic filter:
Elements in the filters array are combined using the AND condition and by adding a new element to the array. Building on our previous example, here is an example of filter with two conditions:
The orderBy property allows you to sort the response items by ascending or descending values based on one of the properties. Let's add an orderby condition to our example:
Let's combine two orderBy elements and see what our filter looks like:
Making the Request