asana.error.InvalidRequestError: Invalid Request: offset: Your pagination token has expired.

Hi Asana Community,

Accessing asana by Personal Access Token.
client = asana.Client.access_token(ACCESS_TOKEN)

I am requesting list of tasks based on project.
tasks = client.tasks.get_tasks_for_project(project_gid)

Iterating task list and fetching tasks full data by task_gid.
task_data = client.tasks.get_task(task[“gid”])

After fetching full data for some tasks I’m getting the error “asana.error.InvalidRequestError: Invalid Request: offset: Your pagination token has expired.” after approximately 40 minutes.
I’m not setting/using any pagination options. Do you have any idea?

Hi @Mayank_Kumar , welcome to the forum.

I am pretty sure that your pagination is set on your iteration of get_tasks_for_project.

If your application starts to immediately fetch tasks on each page, or if you query all tasks for multiple projects, there are good chances that you have tons of query to execute, that are set in queue.

Example, if you have 1000 projects, and run, for each id in projects, get_tasks_for_project(id)

If project 1 have a 2nd page, it must wait for all results of first page of each 1000 projects, that can be long.

So, when it’s its turn to query 2nd page of project 1, there are good chances that there, the pagination token can be expired.

My suggestion is to query projects one by one, and query all tasks, then ask for 2nd project after.

Hi @Frederic_Malenfant ,

I have 3 projects. I have fixed project_gid for all three projects. And every project have 200-300 tasks.
I’m fetching tasks based on one by one project.
Example - by first project_gid fetching the task_list then iterate task_list to get full details of every individual task by “task_data = client.tasks.get_task(task[“gid”])”. Then after all this process done. I’m fetching task_list for second project_gid.
I believe I’m not using pagination token.

Almost positive the client libraries implement pagination internally so that they can return more than 100 tasks from a library call. You can check the source code to confirm that.

1 Like