Subtasks
For the sake of this test, we created one project and one assignee in that project. Lets check the task that we created to confirm that there are no subtasks in it yet:
Response: HTTP 200, application/json (Hide)
GET /projects/1/tasks/1
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
{
"single": {
"id": 1,
"class": "Task",
"url_path": "\/projects\/1\/tasks\/1",
"name": "Task #1",
"assignee_id": 2,
"delegated_by_id": 1,
"completed_on": null,
"completed_by_id": null,
"is_completed": false,
"comments_count": 0,
"attachments": [],
"labels": [],
"is_trashed": false,
"trashed_on": null,
"trashed_by_id": 0,
"project_id": 1,
"is_hidden_from_clients": false,
"body": "",
"body_formatted": "",
"created_on": 1430164358,
"created_by_id": 1,
"updated_on": 1430164358,
"updated_by_id": 1,
"task_number": 1,
"task_list_id": 0,
"position": 1,
"is_important": false,
"due_on": null,
"estimate": 0,
"job_type_id": 0,
"total_subtasks": 0,
"completed_subtasks": 0,
"open_subtasks": 0
},
"subscribers": [
1,
2
],
"comments": [],
"reminders": [],
"subtasks": [],
"task_list": null,
"tracked_time": 0,
"tracked_expenses": 0
}Lets create a subtask:
Response: HTTP 200, application/json (Hide)
POST /projects/1/tasks/1/subtasks
Payload:
1 2 3 4
{
"body": "Subtask #1",
"assignee_id": 2
}Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
{
"single": {
"id": 1,
"class": "Subtask",
"url_path": "\/projects\/1\/tasks\/1\/subtasks\/1",
"assignee_id": 2,
"delegated_by_id": 1,
"completed_on": null,
"completed_by_id": null,
"is_completed": false,
"is_trashed": false,
"trashed_on": null,
"trashed_by_id": 0,
"created_on": 1430164359,
"created_by_id": 1,
"updated_on": 1430164359,
"name": "Subtask #1",
"task_id": 1,
"project_id": 1,
"due_on": null
}
}Response: HTTP 200, application/json (Hide)
POST /projects/1/tasks/1/subtasks
Payload:
1 2 3
{
"body": "Subtask #2"
}Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
{
"single": {
"id": 2,
"class": "Subtask",
"url_path": "\/projects\/1\/tasks\/1\/subtasks\/2",
"assignee_id": 0,
"delegated_by_id": 0,
"completed_on": null,
"completed_by_id": null,
"is_completed": false,
"is_trashed": false,
"trashed_on": null,
"trashed_by_id": 0,
"created_on": 1430164359,
"created_by_id": 1,
"updated_on": 1430164359,
"name": "Subtask #2",
"task_id": 1,
"project_id": 1,
"due_on": null
}
}When we check our task, we'll see that these subtasks have been added to it:
Response: HTTP 200, application/json (Hide)
GET /projects/1/tasks/1
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
{
"single": {
"id": 1,
"class": "Task",
"url_path": "\/projects\/1\/tasks\/1",
"name": "Task #1",
"assignee_id": 2,
"delegated_by_id": 1,
"completed_on": null,
"completed_by_id": null,
"is_completed": false,
"comments_count": 0,
"attachments": [],
"labels": [],
"is_trashed": false,
"trashed_on": null,
"trashed_by_id": 0,
"project_id": 1,
"is_hidden_from_clients": false,
"body": "",
"body_formatted": "",
"created_on": 1430164358,
"created_by_id": 1,
"updated_on": 1430164359,
"updated_by_id": 1,
"task_number": 1,
"task_list_id": 0,
"position": 1,
"is_important": false,
"due_on": null,
"estimate": 0,
"job_type_id": 0,
"total_subtasks": 2,
"open_subtasks": 2,
"completed_subtasks": 0
},
"subscribers": [
1,
2
],
"comments": [],
"reminders": [],
"subtasks": [
{
"id": 1,
"class": "Subtask",
"url_path": "\/projects\/1\/tasks\/1\/subtasks\/1",
"assignee_id": 2,
"delegated_by_id": 1,
"completed_on": null,
"completed_by_id": null,
"is_completed": false,
"is_trashed": false,
"trashed_on": null,
"trashed_by_id": 0,
"created_on": 1430164359,
"created_by_id": 1,
"updated_on": 1430164359,
"name": "Subtask #1",
"task_id": 1,
"project_id": 1,
"due_on": null
},
{
"id": 2,
"class": "Subtask",
"url_path": "\/projects\/1\/tasks\/1\/subtasks\/2",
"assignee_id": 0,
"delegated_by_id": 0,
"completed_on": null,
"completed_by_id": null,
"is_completed": false,
"is_trashed": false,
"trashed_on": null,
"trashed_by_id": 0,
"created_on": 1430164359,
"created_by_id": 1,
"updated_on": 1430164359,
"name": "Subtask #2",
"task_id": 1,
"project_id": 1,
"due_on": null
}
],
"task_list": null,
"tracked_time": 0,
"tracked_expenses": 0
}Now, lets complete one of the subtasks:
Response: HTTP 200, application/json (Hide)
PUT /complete/subtask/1
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
{
"single": {
"id": 1,
"class": "Subtask",
"url_path": "\/projects\/1\/tasks\/1\/subtasks\/1",
"assignee_id": 2,
"delegated_by_id": 1,
"completed_on": 1430164359,
"completed_by_id": 1,
"is_completed": true,
"is_trashed": false,
"trashed_on": null,
"trashed_by_id": 0,
"created_on": 1430164359,
"created_by_id": 1,
"updated_on": 1430164359,
"name": "Subtask #1",
"task_id": 1,
"project_id": 1,
"due_on": null
}
}We can also reopen a completed subtask:
Response: HTTP 200, application/json (Hide)
PUT /open/subtask/1
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
{
"single": {
"id": 1,
"class": "Subtask",
"url_path": "\/projects\/1\/tasks\/1\/subtasks\/1",
"assignee_id": 2,
"delegated_by_id": 1,
"completed_on": null,
"completed_by_id": null,
"is_completed": false,
"is_trashed": false,
"trashed_on": null,
"trashed_by_id": 0,
"created_on": 1430164359,
"created_by_id": 1,
"updated_on": 1430164360,
"name": "Subtask #1",
"task_id": 1,
"project_id": 1,
"due_on": null
}
}Now that we know how to create and update subtask, lets see how we can move them to trash:
Response: HTTP 200, application/json (Hide)
DELETE /projects/1/tasks/1/subtasks/1
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
{
"single": {
"id": 1,
"class": "Subtask",
"url_path": "\/projects\/1\/tasks\/1\/subtasks\/1",
"assignee_id": 2,
"delegated_by_id": 1,
"completed_on": null,
"completed_by_id": null,
"is_completed": false,
"is_trashed": true,
"trashed_on": 1430164360,
"trashed_by_id": 1,
"created_on": 1430164359,
"created_by_id": 1,
"updated_on": 1430164360,
"name": "Subtask #1",
"task_id": 1,
"project_id": 1,
"due_on": null
}
}To confirm that the subtask is actually moved to trash, we can check is_trashed flag:
Response: HTTP 200, application/json (Hide)
GET /projects/1/tasks/1/subtasks/1
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
{
"single": {
"id": 1,
"class": "Subtask",
"url_path": "\/projects\/1\/tasks\/1\/subtasks\/1",
"assignee_id": 2,
"delegated_by_id": 1,
"completed_on": null,
"completed_by_id": null,
"is_completed": false,
"is_trashed": true,
"trashed_on": 1430164360,
"trashed_by_id": 1,
"created_on": 1430164359,
"created_by_id": 1,
"updated_on": 1430164360,
"name": "Subtask #1",
"task_id": 1,
"project_id": 1,
"due_on": null
}
}