I am trying to show all the tasks inside my page using pagination.
I can able to fetch next 10 results by passing the offset. I need to know how to fetch the previous 10 records by clicking the previous button.
Hi @G111,
There’s no way to “go backward” in time via pagination. I think you’d need to keep track of the date/time of your requests and just ask for a previous time.
@Ross_Grambo do you have any more specific suggestions than this or alternate (i.e. better) guidance?
Hey @G111,
I agree with @Phil_Seeman. There is currently no previous functionality for paging.
Hey @Phil_Seeman @Ross_Grambo =)
Do you happen to know of a way I can create an incremental load when calling an API endpoint?
I saw that in the API response I get an offset parameter in which I can use to pull the next records, but it doesn’t state for how long it is valid and if it will get the records that changed after the last time I got an offset or not…?
Thanks for the assistance!
Hi @Avital_Bargad and welcome to the forum!
@Ross_Grambo might weigh in as well, but I believe you’re confusing pagination with syncing. Pagination and offsets are not meant to be used over a period of time; they are just a way, when you’re wanting to get a chunk of data out of Asana, to break that retrieval into smaller chunks in order to reduce the load on the Asana service.
If you want to do incremental retrieval over time, you want to use the Events endpoints combined with the sync token - that’s the incremental token that will get you the data that’s changed since the last time you synced. For info on that, see:
Thanks @Phil_Seeman!
Could you please tell me a bit more about this endpoint?
I can see in the examples the use of the ID=12345, but I don’t understand if in the system there is a resourceID set for all the projects and I just need to provide it or is it a specific projectID that I need to set as resourceID in the call…?
I did try to check using the workspace if there are any resourceID’s set, but when I tried to use an ID from the response with the events endpoint, I got an error.
This is the link- Get a workspace membership
and I got an error for when I used a specific projectID…
How do I get the resourceID to use in order to make the call using the Event endpoint you shared?
https://developers.asana.com/docs/asana-resource
Thanks in advance!
Yes, exactly!
The Workspace Membership endpoint gets you info on users in a workspace - that won’t help you to get a Project ID. To get all of the projects in a workspace, you can use this endpoint:
https://developers.asana.com/docs/get-multiple-projects
That should get you the Project ID you’ll need to pass to the Events endpoint.
Thanks @Phil_Seeman, could you please provide more info on how to do the incremental load for other endpoints that are not the projects or tasks endpoints?
for example, the team endpoint
The Asana API doesn’t support Events, and thus incremental sync via Events, for anything beyond tasks and projects.
For incremental load on teams and workspaces, you have two options:
- Use webhooks on team_memberships and/or workspace_memberships (see the webhooks documentation here and here).
- Get all teams or workspaces, store that info on your end, then periodically get them again and compare with what you stored to find the changes.
For objects other than teams and workspaces (i.e. tags, custom fields, etc.), your only option is #2 above.