0

How do I get a list of subtasks from a project that are incomplete or are complete?

I'm currently doing

GET /api/1.0/projects/:projectID/tasks?completed_since=now

in order to get all the tasks that are not complete and then looping through the subtasks for each task.

Is there another way?

Shaun
  • 4,057
  • 7
  • 38
  • 48

1 Answers1

0

There isn't currently a way to get all subtasks in a project and filter them by completeness in one request. However, you can fetch all tasks in a project (filtered as you desire) as well as their subtasks, by passing in some I/O options.

  • Specifically, you could pass opt_fields=subtasks which will, for each task result, include the names and IDs of its subtasks.
  • If you pass opt_fields=subtasks.completed_at you will get completion times of the subtasks.
  • If you need extensive information about the subtasks then consider opt_expand=subtasks which will return the full record for each subtask, but due to performance you may wish to just pass in the exact set of fields you want.

Note that for large projects this is an expensive request and you may experience timeouts. The iterative approach is better for scalability.

A balance might be to use opt_fields=subtasks to identify which tasks have subtasks (if most don't), then make separate requests to the /tasks/ID/subtasks endpoint to get the data for those subtasks.

Greg S
  • 2,079
  • 1
  • 11
  • 10
  • Thanks @Greg S I am currently making a reuqest to tasks to get the subtasks and then making one off requests for each sub task. – Shaun Jan 08 '16 at 00:23