I’m using Asana’s Python API to request all completed tasks in a workspace which were due between the previous and next 90 days from now.
I expect there to be hundreds to thousands of results, but Asana limits pagination of responses to 100.
Is there a way I can, similar to other API’s, check of the pagination has more, and if so, request the next 100 until I have them all?
My code currently:
resu
lts = client.tasks.search_tasks_for_workspace(WORKSPACE_GID, {'limit': 100, 'completed': True, 'due_on.after': past.strftime("%Y-%m-%d"), 'due_on.before': future.strftime("%Y-%m-%d")}, opt_pretty=True)
results_list = [r for r in results]
What I imagine the code should look like:
has_more = True
task_list = []
while has_more:
results = client.tasks.search_tasks_for_workspace(WORKSPACE_GID, {'limit': 100, 'completed': True, 'due_on.after': past.strftime("%Y-%m-%d"), 'due_on.before': future.strftime("%Y-%m-%d")}, opt_pretty=True)
results_list = [r for r in results]
task_list += results_list
if not results.has_more:
has_more = False
Any suggestions?