AnsweredAssumed Answered

How do I automatically get the next page of JSON results when getting a list of records via a Rest Get callout?

Question asked by NathanWisman1191 on Aug 26, 2014
Latest reply on Mar 27, 2016 by Adam Arrowsmith
I'm sending a Get request to a REST API. This request returns a JSON response that includes up to 100 records in an array, as well as a link to the next page of 100 results.

How do I get my process to automatically loop through all 100 records...then send another Get to automatically fetch the next 100 records? (and on and on until there are no more records to retrieve)

Here is a sample of the JSON (but imagine this with 100 records in the "records" array, and a URL for the next page.

{"records":
    [{"url":"https://foo.bar.com/api/v4/records/25771895.json",
    "id":123456,
    "name":"test",
    "external_id":null,
    "created_at":"2014-08-04T15:58:50Z",
    "updated_at":"2014-08-04T15:58:50Z",
    "next_page":<NEXT PAGE URL HERE>,
    "previous_page":null,"count":1
}

Outcomes