Get Lead Activities REST API is not returning any activities

Version 3

    Issue Description
    The Get Lead Activities REST API is not returning any activities even though the lead referenced definitely has multiple activities of the type being called.

     

    REQUEST:

    https://[munchkinID].mktorest.com/rest/v1/activities.json?access_token=x&leadIds=123&nextPageToken=ABC&activityTypeIds=46

     

    RESPONSE:

    {

    "requestId": "xyz123",

    "success": true,

    "nextPageToken": "ABC",

    "moreResult": true

    }

     

    Issue Resolution
    The Get Lead Activity REST API are reliant on timestamps for their nextPageToken. Each Get Lead Activity call will go through 300 activities of ALL types from the timestamp placed on the nextPageToken. This is supported by the article http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#/Activities/getLeadActivitiesUsingGET

     

    "By default, the endpoints mentioned in this section will return 300 activity items at a time.  If the moreResult attribute is true, this means that more results are available. Continue to call the endpoint until the moreResult attribute returns false, which means that there are no more results available."

     

    Based on that, the reason why the API call does not return any activities is that it does not find any activities of type 46 in the 300 activities it checks from the timestamp placed on the nextPageToken

     

    So when making a Get Lead Activity call for a specific activity type, ensure that nextPageToken is as close as to the timestamp of the specific activities