Enable to fetch sub-task details without task id

I came across an issue where I am unable to fetch sub-task details without task id.

As in project stories, I can see events for subtasks contain only subtask id which is not sufficient to fetch project and task details.

1 Like

If you are talking about get requests at api you can try ?opt_expand=subtasks or dot notation ?opt_fields=subtasks.name,subtasks.notes…

Accessing subtasks as attributes of a task by using opt_expand=subtasks or similar is not officially supported in the API because it frequently causes stability issues. The only supported way to fetch the subtasks of a task is to call GET /tasks/task-id/subtasks. We’re aware that fetching all subtasks in this way is painful, and we are thinking about additional alternatives that would be easier to use.

1 Like

Hey Joe,

I am really surprised because we don’t have any information about that and still exists in documentation and api explorer fields.

@Diakoptis Can you point to where in the documentation you’re seeing these references? On the tasks reference there is no mention of a subtasks field, and in the explorer I also don’t see an option for subtasks.

This is a silent deprecation: this feature will continue to work if you have already been using it, but we do not recommend using it and have removed it from the docs so that usage doesn’t increase.

Really sorry about that. I was :100: sure that I saw it at api explorer lately. Thanx for mentioned it. I will need to update my code <3

@Diakoptis @Joe_Trollo
Hi Guys,
Thanks for the information. Actually, we are using GET story API using project_id. So whenever we “mark subtask as duplicate and merge into subtask of another project” using UI. we got two stories one give information of subtask “marked this a duplicate of subtask_name” and one “marked [Duplicate] of subtask_name” with their ID and Name. But using subtask id we are not able to fetch project details.

Please help.

Hi Joe,

There are some references on StackOverflow to using opt_fields or opt_expand with subtasks; perhaps you might want to add comments there to let folks know it’s not supported. I’ll PM you with some links.

@anuj If I understand you correctly, what you’re seeing is the normal behavior of subtasks: by default a subtask is not assigned to the project of its parent task even if the parent is assigned to a project.

@Phil_Seeman I am looking for information of subtask details like name, its parent task details by API call using subtask id. So is there any alternative way other than “call GET /tasks/task-id/subtasks” to get subtask details without task id.

Hi @anuj, I’m afraid I don’t think I’m following your scenario.

A subtask is still just a task, so if you have a subtask id and are looking for the details on that task, why can’t you call GET /tasks/task-id where task-id is the id of the subtask?

Are you saying that you did get the task details of the subtask but the Projects field is empty? If so, then that would mean the subtask is not assigned to a project; probably a parent task is assigned to the project.

1 Like

Hi @Phil_Seeman,

Thanks a lot for the solution.

Yes, this API call works for me. But other calls like “GET /tasks with query param Project, workspace” and “GET /projects/project_id/tasks” returns a list of tasks, not subtasks. We can see the subtask details using opt_fields only.

But for GET /tasks/task-id where task-id is the id of the subtask. Its working fine for both task and subtask. In result, the parent field is null for the task and have parent task id as value for subtask.

Thanks again for the solution.

Right, unfortunately you have to make specific separate API calls to get a task’s subtasks. As @Joe_Trollo says up above in this thread:

We’re aware that fetching all subtasks in this way is painful, and we are thinking about additional alternatives that would be easier to use.

One thing you want to be careful of:

Don’t get subtasks in that manner - as Joe says up above in this thread, it’s not supported and can lead to issues. Instead you want to use the supported way of getting subtasks which is the GET /tasks/task-id/subtasks call.