OData Filtering


#1

The YourPayroll API supports OData (v3) filtering for most GET operations.

OData Query Parameters:

The following OData query parameters are supported. Please note that $expand is not supported. Refer http://msdn.microsoft.com/en-us/library/gg309461.aspx for more information about OData query parameters

  • $skip: number of results to skip. e.g.: to skip the first 20 results: $skip=20
  • $top: number of results to retrieve. e.g.: to retrieve the first 10 results: $top=10
  • $orderby: specify the field(s) used to order the collection of results
  • $select: specify a subset of properties to return. Note that $select is only currently supported for the Employee API
  • $filter: filter on field values. e.g.: $filter=FirstName eq 'Paul'
  • NOTE: property names for filtering are capitalised. This is different to the camelCase property names returned in the JSON results
  • See http://msdn.microsoft.com/en-us/library/hh169248(v=nav.71).aspx for more information on available filter operations

Examples

  1. Paging
    The employee list API limits the number of results to 100 per request. To retrieve all results, paging must be implemented:
  • retrieve first 100 records: /api/v2/business/{id}/employee/unstructured?$skip=0&$top=100
  • retrieve the next 100 records: /api/v2/business/{id}/employee/unstructured?$skip=100&$top=100
  • etc
  1. Filtering
  • The following query would return all pay categories that have a default super rate that is not 9.5%
    /api/v2/business/39/paycategory?$filter=DefaultSuperRate ne 9.5M (note the ‘M’ is required in ‘9.5M’ to specify the value as a decimal)
  • The following query would return timesheets that start after 1/4/2016 /api/v2/business/39/timesheet?$filter=StartTime gt datetime'2016-04-01T00:00:00'
  1. Ordering
    The following query would return work types ordered by name
  • /api/v2/business/39/worktype?$orderby=Name
  1. Subset of properties
    The following query would return the Id,First name, Surname and date of birth (the first 100) employees
  • /api/v2/business/{id}/employee/unstructured?$select=Id,FirstName,Surname,DateOfBirth

What is the pagination for returned report data?
#2

Hey Paul,

I just tried skip and take to achieve pagination but I got a response saying $take is not supported.

G


#3

Hi Garth,

Which API endpoint were you hitting?

cheers,
Paul.


#4

Hi @Garth_Belic , the documentation above has been updated. The correct odata parameter is $top , rather than $take

Apologies for the confusion.