Get All Activity For A Lead

Anonymous
Not applicable

Get All Activity For A Lead

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:

{

  "requestId": "15fe4#153d32d6653",

  "success": true,

  "nextPageToken": "5HGU7ZC75UN24BUTN4FPNOQBN35Z4CKALKKTBL5JNUADVGEJNW3A====",

  "moreResult": true

}

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?

Thanks.

12 REPLIES 12
Grégoire_Miche2
Level 10

Re: Get All Activity For A Lead

Hi Sean,

My understanding is that you will need to export them all and filter out from the exported data.

-Greg

Anonymous
Not applicable

Re: Get All Activity For A Lead

Hi Greg,

Is there an easy way to export all activity for a lead through the REST API?

Sean

Grégoire_Miche2
Level 10

Re: Get All Activity For A Lead

Hi Sean,

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.

-Greg

Anonymous
Not applicable

Re: Get All Activity For A Lead

Hi Greg,

Right, I guess my question is how do I determine what pageToken to get to retrieve all of the data?

Thanks,

Sean

Grégoire_Miche2
Level 10

Re: Get All Activity For A Lead

Hi Sean,

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.

-Greg

Anonymous
Not applicable

Re: Get All Activity For A Lead

Greg,

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.

Thanks,

Sean

Grégoire_Miche2
Level 10

Re: Get All Activity For A Lead

Hi Sean,

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.

-Greg

Anonymous
Not applicable

Re: Get All Activity For A Lead

Hi Greg,

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?

Thanks,

Sean

Grégoire_Miche2
Level 10

Re: Get All Activity For A Lead

Hi Sean,

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.

-Greg