For any given lead I know I can get it's Activity through the Get Lead Activities endpoint. My problem is I want to get the first ever activity recorded for that lead all the way to the last. Is there a way to do this? If I try I date set way in the past (epoch) I get the following response:
Would I have to go through each pageToken till I get data? Is there a way to get the date of the first activity record for a lead?
Other than the Get Lead Activities » Marketo Developers endpoint, no. This endpoint will really return all the activities. Then you will be able to filter the resulting files.
I am not a dev, but my understanding is that the first set of retreived data will come with a pagetoken that will enable you to continue fetching, 300 rows at a time. When you have exhausted all the activities, the pagetoken will return empty with the last set of data.
Thanks for all your replies. I do understand I can continue getting all activities until they are exhausted. I am having problems getting the earliest data efficiently. I need to figure out what date to use in the Get Paging token call to use in my first call to Get Lead Activities that will ensure I get the first activity that exists.
You cannot use the Get Paging Token since you do not know the date in the first place The get paging token is the date at which you want to start returning the activities, but you cannot know, when you set that date, if there is data older or not.
I do not see any other possibility than fetching all the data for the lead with the getactivity and determine what is the earliest one when you have them all.
The problem stems from when fetching the activity for the Lead the nextPageToken is required so I cannot simply return all activities. This is looking like it is impossible in the REST API. I tested this with the SOAP API and I can accomplish getting all activities for a lead very easily. Do you know if there are plans to deprecate the SOAP API anytime in the future?
I think you are making a mistake here. We have done some dev in the past that retrieve all activities without any issue.
The nextpageToken is not provided by the Get Paging API, it is return by the GetActivity API, only if there are some records left to fetch.