I am trying to get all the events on all the projects in the past and then setup a daily scheduled job to incrementally fetch all the events occurred in past day.
This is what I am thinking of doing:
Get all the workspaces
Get all projects of the workspace
Get all events on each project.
I tried getting the events on the project, and the first request fails giving a sync token(as expected)
Bow when I use this sync token, I got today’s events data once and then ˆ dont get anything when I repeat the same process.
Also, is there a filter in request to get the last day events only?
And is the sync used for paging or is there any other purpose?
The sync token used with our events endpoint is basically a cursor or checkpoint. When you fetch all of the events with the same cursor, it should give you back the same thing plus any new events (i.e. if your cursor is abcdef1234567890 and you got it at 1:00 PM, every time you pass abcdef1234567890 in the request you should get all of the events since 1:00 PM until the current time - the time of the request). Note that making a request to the events endpoint will pass back a new cursor that represents “now” (the time the request was made), so if you make a subsequent request with the new cursor, you will only get the events that happened since that time.
Our events are intended to be used for something close to real-time updates, and using them once per day is stretching things a bit; they do expire after a short while. They are also only a best-effort resource for real-time sync and sometimes (particularly if Asana is having an issue) they can end up getting lost.
If you have a paid Asana organization or team, however, you can use our search API to more reliably get exactly what you’re looking for with the modified_at.before and modified_at.after filters. Note that our search API doesn’t support pagination in quite the same way as our other API endpoints, but there is a workaround described in that document for using the creation time of the task to get the effect of being able to paginate through the results. I’d recommend this approach for getting all task modifications that have happened across an entire organization, as it’s much faster and more efficient than requesting updates for every project.
Hi Matt
Thanks for the info. This is helpful. But just to be clear that I understood properyl:
I make 1st request at 1pm and got a token abc12 and no data as no token was passed
Make request at 1pm with token abc12, and you get all data from 12-1 and also get a new token(lets call it abc13)
If I make a request again at 2pm with abc13 token, I will get all events from 1-2 and a new token abc14 and so on.
Question here:
If I make a call at 2pm with token abc12 instead of abc13, would it give all events from 12-2?
Also can i use the same token for all resources? I see that only some of the resources are giving events and the I get a token too old error for the other resources. Please confirm.