microsoft-todo

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Drive Microsoft To Do via Microsoft Graph with
curl + jq
. The user's OAuth bearer token is in
$MICROSOFT_TODO_TOKEN
; every call needs
Authorization: Bearer $MICROSOFT_TODO_TOKEN
. Base URL:
https://graph.microsoft.com/v1.0
.
Failures are
{"error":{"code","message"}}
— show
message
verbatim.
401
means the token expired (re-install).
403
/
ErrorAccessDenied
on a write means the user only granted
Tasks.Read
→ ask them to re-connect with read+write.
bash
G="https://graph.microsoft.com/v1.0"; AUTH="Authorization: Bearer $MICROSOFT_TODO_TOKEN"
通过
curl + jq
借助Microsoft Graph驱动Microsoft To Do。用户的OAuth承载令牌存储在
$MICROSOFT_TODO_TOKEN
中;每次调用都需要
Authorization: Bearer $MICROSOFT_TODO_TOKEN
。基础URL:
https://graph.microsoft.com/v1.0
.
失败响应格式为
{"error":{"code","message"}}
——直接显示
message
内容。
401
表示令牌已过期(重新安装)。写入操作时出现
403
/
ErrorAccessDenied
意味着用户仅授予了
Tasks.Read
权限→请用户重新连接并授予读写权限。
bash
G="https://graph.microsoft.com/v1.0"; AUTH="Authorization: Bearer $MICROSOFT_TODO_TOKEN"

Task lists

任务列表

curl -sS -H "$AUTH" "$G/me/todo/lists" | jq '.value[] | {id, displayName, wellknownListName}'
undefined
curl -sS -H "$AUTH" "$G/me/todo/lists" | jq '.value[] | {id, displayName, wellknownListName}'
undefined

Tasks

任务

bash
LIST="LIST_ID"
bash
LIST="LIST_ID"

Open tasks in a list (filter notStarted/inProgress; $top caps page size)

列表中的未完成任务(筛选notStarted/inProgress状态;$top限制每页数量)

curl -sS -H "$AUTH"
"$G/me/todo/lists/$LIST/tasks?$filter=status ne 'completed'&$top=50"
| jq '.value[] | {id, title, status, due: .dueDateTime.dateTime}'
curl -sS -H "$AUTH"
"$G/me/todo/lists/$LIST/tasks?$filter=status ne 'completed'&$top=50"
| jq '.value[] | {id, title, status, due: .dueDateTime.dateTime}'

Create (confirm first). dueDateTime/reminderDateTime are optional.

创建任务(需先确认)。dueDateTime/reminderDateTime为可选参数。

curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json"
-d '{"title":"Follow up with Alex","dueDateTime":{"dateTime":"2026-06-30T17:00:00","timeZone":"UTC"}}'
"$G/me/todo/lists/$LIST/tasks" | jq '{id, title, status}'
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json"
-d '{"title":"Follow up with Alex","dueDateTime":{"dateTime":"2026-06-30T17:00:00","timeZone":"UTC"}}'
"$G/me/todo/lists/$LIST/tasks" | jq '{id, title, status}'

Complete: PATCH the task with {"status":"completed"}

完成任务:通过PATCH请求将任务状态设置为{"status":"completed"}

curl -sS -X PATCH -H "$AUTH" -H "Content-Type: application/json"
-d '{"status":"completed"}' "$G/me/todo/lists/$LIST/tasks/TASK_ID" | jq '{title, status}'
undefined
curl -sS -X PATCH -H "$AUTH" -H "Content-Type: application/json"
-d '{"status":"completed"}' "$G/me/todo/lists/$LIST/tasks/TASK_ID" | jq '{title, status}'
undefined

Gotchas

注意事项

  • OData params (
    $filter
    ,
    $top
    ,
    $select
    ) need the
    $
    escaped in the shell (
    \$filter
    ) and URL-encoded spaces — quote the whole URL.
  • wellknownListName: "defaultList"
    is the user's default "Tasks" list — a good fallback when they don't name a list.
  • Pagination via
    @odata.nextLink
    ; follow it for "all tasks".
  • OData参数(
    $filter
    $top
    $select
    )在shell中需要对
    $
    进行转义(
    \$filter
    ),并且空格需要进行URL编码——请将整个URL用引号包裹。
  • wellknownListName: "defaultList"
    是用户的默认“Tasks”列表——当用户未指定列表时,这是一个不错的备选。
  • 通过
    @odata.nextLink
    进行分页;如需获取“所有任务”,请跟随该链接。