Supplementing our existing article on querying records using RESTful services let's look how a few extra features can help in integration. These features apply to all services in Fusion Cloud Applications, including custom object services.
By default 25 records are returned in the REST response payloads. This may not be all values however, and is clear when you see the hasMore=true value shown at the top of the payload. You can actually change this by specifying the limit parameter in the request URL. This parameter accepts a number, up to 500 which is the internal upper limit set in the ADF runtime environment.
For example, get up to 200 records: [URL]/crmCommonApi/resources/11.1.11/resources?limit=200
Potentially useful in combination with the limit parameter above, the offset parameter can use used to return records from one particular starting point. It accepts a number from which to begin returning records. Note this is an index, so the first record is 0 (not 1).
For example, return the second set of 50 records: [URL]/crmCommonApi/resources/11.1.11/resources?limit=100&offset=50
Rather than getting the whole response payload, it is possible to get just the data you need. By including the fields parameter in the URL you can ensure a small discrete response is returned. This equates to the <findAttributes> element used in the findCriteria part of a similar SOAP service request.
For example, get the PartyId and PartyName of up to 50 resources: [URL]/crmCommonApi/resources/11.1.11/resources?limit=50&fields=PartyId,PartyName
As discussed in depth within this article, searchable attributes can be specified in the request URL with a filtering condition.
For example, return the PartyName of the resource with a specified Id: [URL]/crmCommonApi/resources/11.1.11/resources?Fields=PartyName&q=PartyId=300000000691539
Used with query parameters, by specifying the totalResults parameter you add an extra value at the end of the response that has a count of matching records. This actually duplicates the same as the count value already shown at the start of every response.
For example, show the number of resources with surname 'Bingham': [URL]/crmCommonApi/resources/11.1.11/resources?q=PersonLastName='Bingham'&totalResults=true
It is possible to get your results sorted by one or more specified fields. The field name is appended with postfix :asc or :desc to specify the order. Multiple sort attributes are supported, used with comma separation.
For example, get the results of a query descending by PartyNumber: [URL]/crmCommonApi/resources/11.1.11/resources?q=PersonLastName='Bingham'&orderBy=PartyNumber:desc