Pagination Token, Pagination error while connecting to Python Api

HTTP response headers: HTTPHeaderDict({‘Date’: ‘Fri, 15 Sep 2023 13:26:08 GMT’, ‘Content-Type’: ‘application/json; charset=UTF-8’, ‘Content-Length’: ‘208’, ‘Connection’: ‘keep-alive’, ‘Server’: ‘nginx’, ‘x-frame-options’: ‘DENY’, ‘x-xss-protection’: ‘1; mode=block’, ‘x-content-type-options’: ‘nosniff’, ‘content-security-policy’: “report-uri https://app.asana.com/-/csp_report?report_only=false;default-src ‘none’;frame-src ‘none’;frame-ancestors ‘none’”, ‘x-asana-api-version’: ‘1.1’, ‘asana-change’: ‘name=new_user_task_lists;info=Update on our planned API changes to user task lists (a.k.a. My Tasks), name=new_goal_memberships;info=https://forum.asana.com/t/launched-team-sharing-for-goals/378601;affected=true’, ‘x-robots-tag’: ‘none’})
HTTP response body: b’{“errors”:[{“message”:“offset: Your pagination token is invalid.”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: Errors”}]}’

I have been getting this error, I tried all the ways to fetch tasks for a projects in case when there are more than 1000 tasks for projects. Have been getting pagination error , even using Asana Api and Asana library as well in Python. Kindly help me resolve this issue

I’m not familiar with the Python library, but if you’re getting the error with the native API without using a client library, please post your code where you’re doing the request. (You can also post the Python code where you’re doing the request if you like, as others here do know that library.)

I don’t know in which context you run your query, but pagination token does not last very long.

They are used to fetch all pages without wait between them.

You can’t use it, for example to display data in your screen, and hit the “next page” button to display more data.
It will not work.
I once had that issue, I think it was between 5 and 15 minutes, I am not sure, but these pagination token expires quickly.

1 Like

I am trying To fetch the list of all the tasks in a project to further fetch the values of their custom fields of each task, but my code keeps failing as the number of tasks in few projects is more than 1000 and Asana API truncates the result after 1000 records, So I have been trying to do with pagination but it still keeps failing, can you please help me how to deal with this situation of returing all the GIDs of the tasks in a project when the number of tasks exceeds 1000