訂單工作
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以根據使用者的需求和偏好以特定順序排列工作。你可以將工作移至其他工作 (parent
) 並/或移至其他工作 (previous
) 之後。

如要移動工作,請使用以下特殊參數將經過驗證的 POST
要求傳送至下列網址:
parent
參數
- 指定應插入新工作的父項任務 ID。省略此參數會將工作置於清單的頂層。
previous
參數
- 指定應插入新任務的工作 ID。如果省略這個參數,系統會將工作置於子清單的第一個位置。
網址格式為:
https://www.googleapis.com/tasks/v1/lists/taskListID
/tasks/taskID
/move?parent=parentTaskID
&previous=previousTaskID
將 taskListID
、taskID
、parentTaskID
和 previousTaskID
替換為適當的值。
注意:您可以使用特殊的 taskListID
值 @default
來參照已驗證使用者的預設工作清單。
成功時,伺服器會傳回 HTTP 200 OK
狀態碼和新的工作資料。
範例
通訊協定
要求:
POST /tasks/v1/lists/@default/tasks/taskID
/move?parent=parentTaskID
&previous=previousTaskID
回應:
HTTP/1.1 200 OK
{
id: "taskID",
kind: "tasks#task",
selfLink: "https://www.googleapis.com/tasks/v1/lists/@default/tasks/taskID",
etag: "newETag",
title: "New Task",
notes: "Please complete me",
updated: "2010-10-15T11:30:00.000Z",
...,
parent: "parentTaskID",
position: "newPosition",
...
}
Java
import com.google.api.services.tasks.v1.Tasks.TasksOperations.Move;
...
Move move = service.tasks.move("@default", "taskID");
move.setParent("parentTaskID");
move.setPrevious("previousTaskID");
Task result = move.execute();
// Print the new values.
System.out.println(result.getParent());
System.out.println(result.getPosition());
Python
result = service.tasks().move(tasklist='@default', task='taskID', parent='parentTaskID', previous='previousTaskID').execute()
# Print the new values.
print result['parent']
print result['position']
PHP
$result = $service->moveTasks('taskID', '@default', null, 'parentTaskID', 'previousTaskID');
/*
* Print the new values.
*/
echo $result->getParent();
echo $result->getPosition();
.NET
Task result = service.Tasks.Move("@default", "taskID",
parent: "parentTaskID", previous: "previousTaskID").Fetch();
// Print the new values.
Console.WriteLine(result.Parent);
Console.WriteLine(result.Position);
注意:您也可以在建立新工作時,使用 parent
和 previous
參數。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],null,["# Order Tasks\n\nYou can organize tasks in a specific order to suit the user's needs and preferences. A task can be moved under another task (`parent` task) and/or move to be after another task (`previous`).\n\nTo move a task, send an authenticated `POST` request to the following URL with these special parameters:\n\nThe `parent` parameter\n: Specifies the ID of the parent task under which the new task should be inserted; omitting this parameter places the task in the top level of the list.\n\nThe `previous` parameter\n: Specifies the ID of the task after which the new task should be inserted; omitting this parameter places the task in the first position of the sublist.\n\nThe URL is of the form: \n\n https://www.googleapis.com/tasks/v1/lists/taskListID/tasks/taskID/move?parent=parentTaskID&previous=previousTaskID\n\nWith the appropriate values in place of `taskListID`, `taskID`, `parentTaskID` and `previousTaskID`.\n\n**Note** : The special `taskListID` value `@default` can be used to refer to the authenticated user's default task list.\n\nUpon success, the server responds with an HTTP `200 OK` status code and the new task data.\n\nExample\n=======\n\n### Protocol\n\nRequest: \n\n POST /tasks/v1/lists/@default/tasks/taskID/move?parent=parentTaskID&previous=previousTaskID\n\nResponse: \n\n```http\nHTTP/1.1 200 OK\n\n{\n id: \"taskID\",\n kind: \"tasks#task\",\n selfLink: \"https://www.googleapis.com/tasks/v1/lists/@default/tasks/taskID\",\n etag: \"\u003cvar translate=\"no\"\u003enewETag\u003c/var\u003e\",\n title: \"New Task\",\n notes: \"Please complete me\",\n updated: \"2010-10-15T11:30:00.000Z\",\n ...,\n parent: \"\u003cvar translate=\"no\"\u003eparentTaskID\u003c/var\u003e\",\n position: \"\u003cvar translate=\"no\"\u003enewPosition\u003c/var\u003e\",\n ...\n}\n```\n\n### Java\n\n\n```java\nimport com.google.api.services.tasks.v1.Tasks.TasksOperations.Move;\n...\n\nMove move = service.tasks.move(\"@default\", \"\u003cvar translate=\"no\"\u003etaskID\u003c/var\u003e\");\nmove.setParent(\"\u003cvar translate=\"no\"\u003eparentTaskID\u003c/var\u003e\");\nmove.setPrevious(\"\u003cvar translate=\"no\"\u003epreviousTaskID\u003c/var\u003e\");\nTask result = move.execute();\n\n// Print the new values.\nSystem.out.println(result.getParent());\nSystem.out.println(result.getPosition());\n```\n\n\u003cbr /\u003e\n\n### Python\n\n\n```python\nresult = service.tasks().move(tasklist='@default', task='\u003cvar translate=\"no\"\u003etaskID\u003c/var\u003e', parent='\u003cvar translate=\"no\"\u003eparentTaskID\u003c/var\u003e', previous='\u003cvar translate=\"no\"\u003epreviousTaskID\u003c/var\u003e').execute()\n\n# Print the new values.\nprint result['parent']\nprint result['position']\n```\n\n\u003cbr /\u003e\n\n### PHP\n\n\u003cbr /\u003e\n\n```php\n$result = $service-\u003emoveTasks('\u003cvar translate=\"no\"\u003etaskID\u003c/var\u003e', '@default', null, '\u003cvar translate=\"no\"\u003eparentTaskID\u003c/var\u003e', '\u003cvar translate=\"no\"\u003epreviousTaskID\u003c/var\u003e');\n\n/*\n * Print the new values.\n */\necho $result-\u003egetParent();\necho $result-\u003egetPosition();\n```\n\n\u003cbr /\u003e\n\n### .NET\n\n\u003cbr /\u003e\n\n```transact-sql\nTask result = service.Tasks.Move(\"@default\", \"\u003cvar translate=\"no\"\u003etaskID\u003c/var\u003e\",\n parent: \"\u003cvar translate=\"no\"\u003eparentTaskID\u003c/var\u003e\", previous: \"\u003cvar translate=\"no\"\u003epreviousTaskID\u003c/var\u003e\").Fetch();\n// Print the new values.\nConsole.WriteLine(result.Parent);\nConsole.WriteLine(result.Position);\n```\n\n\u003cbr /\u003e\n\n**Note** : The `parent` and `previous` parameters can also be used while [creating a new task](#creating_task)."]]