SOLVED

Pagination issues with some endpoints

Go to solution
Anonymous
Not applicable

Pagination issues with some endpoints

We are having issues with the pagination using some endpoints, regarding the documentation the API should return the property “moreResult” which indicates if there are more results in subsequent pages.

In these endpoints the “moreResult” property is not coming:

  • /rest/v1/lists.json
  • /rest/v1/lists/{LIST_ID}/leads.json
  • /rest/v1/leads/programs/{PROGRAM_ID}.json
  • /rest/v1/campaigns.json

Request:

/rest/v1/lists.json?batchSize=5&access_token=xxxxxxxxxxxxxx

Response:

{

    "requestId": "f9fc#1605b4c5a14",

    "result": [

        {

            "id": 1001,

            "name": "Tradeshow1",

            "workspaceName": "Default",

            "createdAt": "2015-11-15T20:03:16Z",

            "updatedAt": "2016-12-28T20:17:17Z"

        },

        ........

        ........

        ........

     ],

    "success": true,

    "nextPageToken": "TMXXXAWSCCSRDRWQZ33VCJOFXI======"

}

I think the "nextPAgeToken" property is not reliable to determine if are more results.

Any idea? What can we do?

Thanks in advance,

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
David_Everly
Marketo Employee

Re: Pagination issues with some endpoints

The endpoints that you mention do not return a "moreResult" property.  Rather, they return "nextPageToken" in the case where the result set exceeds the batchSize (which defaults to 300).  To retrieve the entire result set, repeatedly call the endpoint and update nextPageToken with the value that was returned in previous request.  Repeat this until nextPageToken is no longer returned. 

If you have a reproducible case where this process is unreliable, please file a case with Marketo Support.  Sorry for the confusion, we'll get the documentation updated.

View solution in original post

2 REPLIES 2
David_Everly
Marketo Employee

Re: Pagination issues with some endpoints

The endpoints that you mention do not return a "moreResult" property.  Rather, they return "nextPageToken" in the case where the result set exceeds the batchSize (which defaults to 300).  To retrieve the entire result set, repeatedly call the endpoint and update nextPageToken with the value that was returned in previous request.  Repeat this until nextPageToken is no longer returned. 

If you have a reproducible case where this process is unreliable, please file a case with Marketo Support.  Sorry for the confusion, we'll get the documentation updated.

Anonymous
Not applicable

Re: Pagination issues with some endpoints

Hi,

This just bit me as well. It does not look like the docs were ever updated. The Position-Based section of http://developers.marketo.com/rest-api/paging-tokens/​ still says:

When there are more results, the moreResult field is true in the response, and a nextPageToken is returned.

Why not always set "moreResult" for consistency sake?

Thanks,

Ian