We have a use case where when getting tasks for a Project we may want to filter out tasks that fall under a specific section. I’m not seeing it in the schema but is there a way to get the section a task falls under via the
I see we can get tasks by section but it would add quite a few calls, and a lot of fragility, to get all the sections, then get all the tasks for every section that isn’t filtered out, then concatenating them all together and de-duping that list. I would be worried about general failures or hitting the API limit if we did it that way.
There are some possible solutions for your need.
First, your initial guess of querying all sections, choosing the one you want, then getting all tasks for these sections can be good.
But, to avoid limitation issues, set them in queue and query them one by one. Also, you can do that using batch, to get them 5 by 5 for exemple.
You can’t run your query more than 1500 times/minute, and a batch of 5 counts for 5. But, trust me, the api is slow enough that you will not be able to reach that 1500 limit using a queue…
Another solution can be to use the Search API
From that endpoint you can query exactly the sections you need, using:
But, when using the search API, you need to code your pagination differently, sort by date added, and then query the next page based on the last date added of the previous page.
In addition to @Frederic_Malenfant’s suggestions, you can also make your tasks retrieval call like this:
and that will give you the section info for each returned task.
Ah thank you @Phil_Seeman! This is exactly what I was looking for!