Problem with next_page

Hi @Diego_Ramírez,

It looks like you are using our python-asana v5 client library to make your request. As @tjholsman mentioned pagination is enabled by default for v5.

This means that you do not need to provide a limit argument in the query param.

I also tried to reproduce your issue by providing "limit": 95 and "limit":100 and was not able to reproduce your issue.

Here’s a scenario using default auto pagination:

  1. I have a project with 1010 tasks (Let’s call this project 123)
  2. I make an API call with using python-asana v5 client library:
import os
import asana
from asana.rest import ApiException

configuration = asana.Configuration()
configuration.access_token = os.environ["ASANA_PERSONAL_ACCESS_TOKEN"]
api_client = asana.ApiClient(configuration)

# create an instance of the API class
tasks_api_instance = asana.TasksApi(api_client)
opts = {
    'project': "123",
}

try:
    # Get multiple tasks
    api_response = tasks_api_instance.get_tasks(opts)
    count = 0
    for data in api_response:
        count += 1

    print(f"Total tasks: {count}")
except ApiException as e:
    print("Exception when calling TasksApi->get_tasks: %s\n" % e)

I get back the following output:

Total tasks: 1010

If you would like to disable the auto-pagination feature for v5 and just get the pages yourself see Disabling default pagination behaviour


One thing that could explain your issue is we recently found a bug (Get tasks from a project returns different number of tasks depending on page limit provided) in our API for paginated requests where if the limit you provide ends in the section of a project it causes the next_page to cut off early. By default, our auto pagination specifies a limit of 100 so you may encounter the same issue if you use auto pagination.

Here’s an example scenario:

  • PROJECT_A has a section called SECTION_1
  • PROJECT_A has. a section called SECTION_2
  • SECTION_1 has 5 tasks
  • SECTION_2 has 10 tasks
  • If you make a call to Get multiple tasks endpoint and specify a limit of 5 the API will return next_page of null after those 5 tasks → technically this should not happen and it should return 15 tasks, so this is the bug that we are currently fixing.

To get around this, I recommend changing the default limit like you have to a limit that doesn’t end in a section or make a non-paginated request (turn off auto pagination feature and make a request without a limit query param —> Caveat if a project has more than 1000 tasks this will throw an error and tell you to use pagination)

2 Likes