Pagination Error for tasks

Hi,
This code was previously working fine but is throwing the error -
InvalidRequestError: Invalid Request: The result is too large. You should use pagination (may require specifying a workspace)!

I get this error when i run the below code

tasks = client.tasks.find_by_project(xxxxxxx, {“opt_expand”:“name,
approval_status,completed, completed_at,completed_by,
created_at,dependencies,dependents,due_at,due_on,memberships,
modified_at,notes, num_subtasks,resource_subtype,start_on,assignee,
followers,parent,permalink_url,projects,tags,custom_fields”}, iterator_type=None)

Surprisingly i dont get this error when i run get_tasks but i want to know how i can expand all the fields in the result, any help is appreciated.

I might be captain obvious here, but you should paginate. Did you look at the doc regarding pagination?

Which language is that? Are you using their client library?

1 Like

Hi,
I am using the python client library, and in one of the topics it’s mentioned that I wouldn’t have to paginate and this would be handled inherently, I am confused especially as I’m unsure on how to paginate and what values to sort the data by

I am using the nodeJS library and indeed pagination is available within the client. I don’t know python enough, I would just be quoting the docs and the Collections section of the python lib GitHub - Asana/python-asana: Official Python client library for the Asana API v1 sorry

@Nabeelah,

Pagination is built into the client libraries; you shouldn’t have to do anything about it yourself.

1 Like

@phil_seeman

That’s what I assumed and was very surprised to get this error, any idea why I’m encountering this?

1 Like

Oh sorry, I missed the initial error you mentioned. I have no idea, I’m afraid, I’m totally unfamiliar with the Python library.

@Ross_Grambo?

Hello @Nabeelah,

You’re likely getting this error now because you’re not using pagination and your data is getting too big. The client library does pagination for you automatically via the iterator. In your request, you’ve included iterator_type=None. This is explicitly saying don’t use pagination and give me all the results as one big list.

To fix this, you should either take out iterator_type=None or explicitly set it to iterator_type="items". This means you’ll now get an iterator, and you’ll need to loop through all the objects instead of treating them like a list.

Let me know if this doesn’t help or you have any questions!

4 Likes