Response Paging

Response paging is used when the response returned by the service contains a url to the next page/set of records.

Response paging is available for JSON and XML data formats.

Both formats use the same logic.

  1. The first page of data is returned by the service will be the url specified in the Reader or Lookup.
  2. The next page of data is determined by obtaining the value from the response specified by the Paging Path of the Webservice Behaviour.
  3. If the value is a relative URL, it will be appended to the Base URL from the Webservice Behaviour.
  4. The next page of records will be obtained by querying the service with the URL from step 3.
  5. Steps 2-4 will be repeated until the response doesn’t contain the element or if the element value is empty.

JSON

The JSON response paging settings only require two parameters to be set.

  • Base Url
    • Next page elements are often a relative URL; a base URL is required to execute the next request.
  • Paging Path
    • The JPath of the next page element.

Example Request

Consider the following JSON returned by the first request.

{
  "nextRecordsUrl" : "/services/data/v20.0/query/01gD0000002HU6KIAW-2000",
  "done" : false,
  "totalSize" : 3028, 
   "records": [ { 
      "attributes": { 
          "type": "Account", 
          "url": "/services/data/v20.0/sobjects/Account/001D000000IRFmaIAH" 
        },
        "Name": "Rick and Co Services"
      },
      {
        "attributes": {
          "type": "Account",
          "url": "/services/data/v20.0/sobjects/Account/001D000000IomazIAB"
        },
        "Name": "Realisable Software Ltd"
      },...
}

When this response is returned the paging uses the Paging Path defined in the webservice behaviour to extract the URL to be used. If this is relative URL the value is joined with the Base URL for the next request. In this instance:

https://pagedservice.com/api/services/data/v20.0/query/01gD0000002HU6KIAW-2000

This process loops until either the nextRecordsUrl element is not present or the value is empty.

Xml

The Xml response paging settings only require two parameters to be set.

  • Base Url
    • Next page elements are often a relative URL; a base URL is required to execute the next request.
  • Paging Path
    • The XPath of the next page element.

Example Request

Consider the following Xml returned by the first request.

<response>
  <done>false</done>
  <nextRecordsUrl>/services/data/v20.0/query/01gD0000002HU6KIAW-2000</nextRecordsUrl>
  <records>
  <element>
     <Name>Rick and Co Services</Name>
     <attributes>
       <type>Account</type>
       <url>/services/data/v20.0/sobjects/Account/001D000000IRFmaIAH</url>
     </attributes>
   </element>
   <element>
     <Name>Realisable Software Ltd</Name>
     <attributes>
       <type>Account</type>
         <url>/services/data/v20.0/sobjects/Account/001D000000IomazIAB</url>
      </attributes>
    </element>
  </records>
  <totalSize>3028</totalSize>
</response>

When this response is returned the paging uses the Paging Path defined in the webservice behaviour to extract the URL to be used. If this is relative URL the value is joined with the Base URL for the next request. In this instance:

https://pagedservice.com/api/services/data/v20.0/query/01gD0000002HU6KIAW-2000

This process loops until either the nextRecordsUrl element is not present or the value is empty.