跳至主要内容
REST API 现在已实现版本控制。 更多信息,请参阅“关于 API 版本控制”。

用于问题指派人的 REST API 端点

使用 REST API 管理问题和拉取请求中的指派人。

关于问题和拉取请求的指派人

您可以使用 REST API 查看、添加和删除问题和拉取请求中的指派人。每个拉取请求都是一个问题,但并非每个问题都是一个拉取请求。因此,针对这两个功能的“共享”操作(例如管理指派人、标签和里程碑)都提供在“问题”端点中。

列出指派人

“列出指派人”的细粒度访问令牌

此端点可以使用以下细粒度令牌类型:

细粒度令牌必须至少具有以下权限集之一

  • “问题”代码仓库权限(读取)
  • “拉取请求”代码仓库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“列出指派人”的参数

标头
名称、类型、描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称、类型、描述
owner 字符串 必填

代码仓库的帐户所有者。名称不区分大小写。

repo 字符串 必填

代码仓库的名称,不包含.git扩展名。名称不区分大小写。

查询参数
名称、类型、描述
per_page 整数

每页结果数(最大 100)。更多信息,请参阅“在 REST API 中使用分页”。

默认值:30

page 整数

要获取的结果的页码。更多信息,请参阅“在 REST API 中使用分页”。

默认值:1

“列出指派人”的 HTTP 响应状态代码

状态代码描述
200

OK

404

资源未找到

“列出指派人”的代码示例

请求示例

get/repos/{owner}/{repo}/assignees
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/assignees

响应

状态:200
[ { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } ]

检查用户是否可以被指派

检查用户是否有权被指派到此代码仓库中的问题。

如果可以将assignee指派到代码仓库中的问题,则返回不包含内容的204标头。

否则返回404状态代码。

“检查用户是否可以被指派”的细粒度访问令牌

此端点可以使用以下细粒度令牌类型:

细粒度令牌必须至少具有以下权限集之一

  • “问题”代码仓库权限(读取)
  • “拉取请求”代码仓库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“检查用户是否可以被指派”的参数

标头
名称、类型、描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称、类型、描述
owner 字符串 必填

代码仓库的帐户所有者。名称不区分大小写。

repo 字符串 必填

代码仓库的名称,不包含.git扩展名。名称不区分大小写。

assignee 字符串 必填

“检查用户是否可以被指派”的 HTTP 响应状态代码

状态代码描述
204

如果可以将assignee指派到代码仓库中的问题,则返回不包含内容的204标头。

404

否则返回404状态代码。

“检查用户是否可以被指派”的代码示例

请求示例

get/repos/{owner}/{repo}/assignees/{assignee}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/assignees/ASSIGNEE

如果可以将assignee指派到代码仓库中的问题,则返回不包含内容的204标头。

状态:204

向问题添加指派人

向问题添加最多 10 个指派人。不会替换已指派给问题的用户。

“向问题添加指派人”的细粒度访问令牌

此端点可以使用以下细粒度令牌类型:

细粒度令牌必须至少具有以下权限集之一

  • “问题”代码仓库权限(写入)
  • “拉取请求”代码仓库权限(写入)

“向问题添加指派人”的参数

标头
名称、类型、描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称、类型、描述
owner 字符串 必填

代码仓库的帐户所有者。名称不区分大小写。

repo 字符串 必填

代码仓库的名称,不包含.git扩展名。名称不区分大小写。

issue_number 整数 必填

标识问题的数字。

主体参数
名称、类型、描述
assignees 字符串数组

要将此问题指派给的人员的用户名。注意:只有具有推送访问权限的用户才能向问题添加指派人。否则,指派人将被静默忽略。

“向问题添加指派人”的 HTTP 响应状态代码

状态代码描述
201

已创建

“向问题添加指派人”的代码示例

请求示例

post/repos/{owner}/{repo}/issues/{issue_number}/assignees
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/assignees \ -d '{"assignees":["hubot","other_user"]}'

响应

状态:201
{ "id": 1, "node_id": "MDU6SXNzdWUx", "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", "repository_url": "https://api.github.com/repos/octocat/Hello-World", "labels_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/labels{/name}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", "events_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/events", "html_url": "https://github.com/octocat/Hello-World/issues/1347", "number": 1347, "state": "open", "title": "发现了一个bug", "body": "我遇到一个问题。", "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "labels": [ { "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "description": "某些功能无法正常工作", "color": "f29513", "default": true } ], "assignee": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "assignees": [ { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } ], "milestone": { "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", "id": 1002604, "node_id": "MDk6TWlsZXN0b25lMTAwMjYwNA==", "number": 1, "state": "open", "title": "v1.0", "description": "版本1.0的里程碑跟踪", "creator": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "open_issues": 4, "closed_issues": 8, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z", "closed_at": "2013-02-12T13:22:01Z", "due_on": "2012-10-09T23:39:01Z" }, "locked": true, "active_lock_reason": "讨论过于激烈", "comments": 0, "pull_request": { "url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347", "html_url": "https://github.com/octocat/Hello-World/pull/1347", "diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff", "patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch" }, "closed_at": null, "created_at": "2011-04-22T13:33:48Z", "updated_at": "2011-04-22T13:33:48Z", "closed_by": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "author_association": "COLLABORATOR", "state_reason": "已完成" }

从问题中移除指派者

从问题中移除一个或多个指派者。

“从问题中移除指派者”的细粒度访问令牌

此端点可以使用以下细粒度令牌类型:

细粒度令牌必须至少具有以下权限集之一

  • “问题”代码仓库权限(写入)
  • “拉取请求”代码仓库权限(写入)

“从问题中移除指派者”的参数

标头
名称、类型、描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称、类型、描述
owner 字符串 必填

代码仓库的帐户所有者。名称不区分大小写。

repo 字符串 必填

代码仓库的名称,不包含.git扩展名。名称不区分大小写。

issue_number 整数 必填

标识问题的数字。

主体参数
名称、类型、描述
assignees 字符串数组

要从问题中移除的指派者的用户名。注意:只有拥有推送访问权限的用户才能从问题中移除指派者。否则,指派者将被静默忽略。

“从问题中移除指派者”的HTTP响应状态码

状态代码描述
200

OK

“从问题中移除指派者”的代码示例

请求示例

删除/repos/{owner}/{repo}/issues/{issue_number}/assignees
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/assignees \ -d '{"assignees":["hubot","other_user"]}'

响应

状态:200
{ "id": 1, "node_id": "MDU6SXNzdWUx", "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", "repository_url": "https://api.github.com/repos/octocat/Hello-World", "labels_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/labels{/name}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", "events_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/events", "html_url": "https://github.com/octocat/Hello-World/issues/1347", "number": 1347, "state": "open", "title": "发现了一个bug", "body": "我遇到一个问题。", "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "labels": [ { "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "description": "某些功能无法正常工作", "color": "f29513", "default": true } ], "assignee": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "assignees": [ { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } ], "milestone": { "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", "id": 1002604, "node_id": "MDk6TWlsZXN0b25lMTAwMjYwNA==", "number": 1, "state": "open", "title": "v1.0", "description": "版本1.0的里程碑跟踪", "creator": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "open_issues": 4, "closed_issues": 8, "created_at": "2011-04-10T20:09:31Z", "updated_at": "2014-03-03T18:58:10Z", "closed_at": "2013-02-12T13:22:01Z", "due_on": "2012-10-09T23:39:01Z" }, "locked": true, "active_lock_reason": "讨论过于激烈", "comments": 0, "pull_request": { "url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347", "html_url": "https://github.com/octocat/Hello-World/pull/1347", "diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff", "patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch" }, "closed_at": null, "created_at": "2011-04-22T13:33:48Z", "updated_at": "2011-04-22T13:33:48Z", "closed_by": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "author_association": "COLLABORATOR", "state_reason": "已完成" }

检查用户是否可以指派到问题

检查用户是否有权被指派到特定问题。

如果可以将assignee指派到此问题,则返回不包含内容的204状态码。

否则返回404状态代码。

“检查用户是否可以指派到问题”的细粒度访问令牌

此端点可以使用以下细粒度令牌类型:

细粒度令牌必须至少具有以下权限集之一

  • “问题”代码仓库权限(读取)
  • “拉取请求”代码仓库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“检查用户是否可以指派到问题”的参数

标头
名称、类型、描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称、类型、描述
owner 字符串 必填

代码仓库的帐户所有者。名称不区分大小写。

repo 字符串 必填

代码仓库的名称,不包含.git扩展名。名称不区分大小写。

issue_number 整数 必填

标识问题的数字。

assignee 字符串 必填

“检查用户是否可以指派到问题”的HTTP响应状态码

状态代码描述
204

如果可以将assignee指派到issue_number的响应

404

如果不可以将assignee指派到issue_number的响应

“检查用户是否可以指派到问题”的代码示例

请求示例

获取/repos/{owner}/{repo}/issues/{issue_number}/assignees/{assignee}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/assignees/ASSIGNEE

如果可以将assignee指派到issue_number的响应

状态:204