拉取请求审查的 REST API 端点
使用 REST API 与拉取请求审查进行交互。
关于拉取请求评审
拉取请求评审是拉取请求评审评论的集合,按状态分组,并包含可选的正文评论。
列出拉取请求的评审
列出指定拉取请求的所有评审。评审列表按时间顺序返回。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github-commitcomment.raw+json
: 返回原始 Markdown 正文。响应将包含body
。如果未传递任何特定媒体类型,则为默认值。application/vnd.github-commitcomment.text+json
: 返回 Markdown 正文的纯文本表示形式。响应将包含body_text
。application/vnd.github-commitcomment.html+json
: 返回从正文的 Markdown 渲染的 HTML。响应将包含body_html
。application/vnd.github-commitcomment.full+json
: 返回原始、文本和 HTML 表示形式。响应将包含body
、body_text
和body_html
。
“列出拉取请求的评审”的细粒度访问令牌
此端点与以下细粒度令牌类型一起使用
细粒度令牌必须具有以下权限集
- “拉取请求”存储库权限(读取)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。
“列出拉取请求的评审”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
owner string 必需存储库的帐户所有者。名称不区分大小写。 |
repo string 必需存储库的名称,不含 |
pull_number integer 必需标识拉取请求的编号。 |
名称、类型、描述 |
---|
per_page integer 每页结果数(最大 100)。有关更多信息,请参阅 "在 REST API 中使用分页." 默认: |
page 整数 要获取的结果页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
“列出拉取请求的评论”的 HTTP 响应状态码
状态码 | 描述 |
---|---|
200 | 评论列表按时间顺序返回。 |
“列出拉取请求的评论”的代码示例
请求示例
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/pulls/PULL_NUMBER/reviews
评论列表按时间顺序返回。
状态:200
[ { "id": 80, "node_id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=", "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 }, "body": "Here is the body for the review.", "state": "APPROVED", "html_url": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80", "pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/12", "_links": { "html": { "href": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80" }, "pull_request": { "href": "https://api.github.com/repos/octocat/Hello-World/pulls/12" } }, "submitted_at": "2019-11-17T17:43:43Z", "commit_id": "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091", "author_association": "COLLABORATOR" } ]
为拉取请求创建评论
在指定的拉取请求上创建评论。
此端点会触发通知。使用此端点过快创建内容可能会导致二次速率限制。有关更多信息,请参阅“API 速率限制”和“使用 REST API 的最佳实践”。
在PENDING
状态下创建的拉取请求审查不会提交,因此响应中不包含submitted_at
属性。要为拉取请求创建待处理审查,请将event
参数留空。有关提交PENDING
审查的更多信息,请参阅“提交拉取请求审查”。
注意:要评论文件中的特定行,您需要先确定该行在差异中的位置。要查看拉取请求差异,请将application/vnd.github.v3.diff
媒体类型添加到对获取拉取请求端点的调用的Accept
标头中。
position
值等于您要添加评论的文件中第一个“@@”块标题以下的行数。紧接在“@@”行下面的行是位置 1,下一行是位置 2,依此类推。差异中的位置会继续增加,穿过空白行和额外的块,直到新文件的开头。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github-commitcomment.raw+json
: 返回原始 Markdown 正文。响应将包含body
。如果未传递任何特定媒体类型,则为默认值。application/vnd.github-commitcomment.text+json
: 返回 Markdown 正文的纯文本表示形式。响应将包含body_text
。application/vnd.github-commitcomment.html+json
: 返回从正文的 Markdown 渲染的 HTML。响应将包含body_html
。application/vnd.github-commitcomment.full+json
: 返回原始、文本和 HTML 表示形式。响应将包含body
、body_text
和body_html
。
用于“为拉取请求创建审查”的细粒度访问令牌
此端点与以下细粒度令牌类型一起使用
细粒度令牌必须具有以下权限集
- “拉取请求”存储库权限(写入)
用于“为拉取请求创建审查”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
owner string 必需存储库的帐户所有者。名称不区分大小写。 |
repo string 必需存储库的名称,不含 |
pull_number integer 必需标识拉取请求的编号。 |
名称、类型、描述 | ||||||||
---|---|---|---|---|---|---|---|---|
commit_id string 需要审查的提交的 SHA。如果不使用最新的提交 SHA,如果后续提交修改了您指定为 | ||||||||
body string 当使用 | ||||||||
event string 您要执行的审查操作。审查操作包括: 可以是以下之一: | ||||||||
comments 对象数组 使用下表指定草稿审查评论的位置、目标和内容。 | ||||||||
|
名称、类型、描述 |
---|
path 字符串 必填需要审查评论的文件的相对路径。 |
position 整数 您要添加审查评论的 diff 中的位置。请注意,此值与文件中的行号不同。 |
body 字符串 必填审查评论的文本。 |
line 整数 |
side 字符串 |
start_line 整数 |
start_side 字符串 |
“为拉取请求创建审查”的 HTTP 响应状态代码
状态码 | 描述 |
---|---|
200 | OK |
403 | 禁止 |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
“为拉取请求创建审查”的代码示例
请求示例
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/pulls/PULL_NUMBER/reviews \ -d '{"commit_id":"ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091","body":"This is close to perfect! Please address the suggested inline change.","event":"REQUEST_CHANGES","comments":[{"path":"file.md","position":6,"body":"Please add more information here, and fix this typo."}]}'
响应
状态:200
{ "id": 80, "node_id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=", "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 }, "body": "This is close to perfect! Please address the suggested inline change.", "state": "CHANGES_REQUESTED", "html_url": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80", "pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/12", "_links": { "html": { "href": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80" }, "pull_request": { "href": "https://api.github.com/repos/octocat/Hello-World/pulls/12" } }, "submitted_at": "2019-11-17T17:43:43Z", "commit_id": "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091", "author_association": "COLLABORATOR" }
获取拉取请求的审查
通过 ID 获取拉取请求评审。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github-commitcomment.raw+json
: 返回原始 Markdown 正文。响应将包含body
。如果未传递任何特定媒体类型,则为默认值。application/vnd.github-commitcomment.text+json
: 返回 Markdown 正文的纯文本表示形式。响应将包含body_text
。application/vnd.github-commitcomment.html+json
: 返回从正文的 Markdown 渲染的 HTML。响应将包含body_html
。application/vnd.github-commitcomment.full+json
: 返回原始、文本和 HTML 表示形式。响应将包含body
、body_text
和body_html
。
用于“获取拉取请求评审”的细粒度访问令牌
此端点与以下细粒度令牌类型一起使用
细粒度令牌必须具有以下权限集
- “拉取请求”存储库权限(读取)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。
“获取拉取请求评审”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
owner string 必需存储库的帐户所有者。名称不区分大小写。 |
repo string 必需存储库的名称,不含 |
pull_number integer 必需标识拉取请求的编号。 |
review_id 整数 必需评审的唯一标识符。 |
“获取拉取请求评审”的 HTTP 响应状态代码
状态码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
“获取拉取请求评审”的代码示例
请求示例
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/pulls/PULL_NUMBER/reviews/REVIEW_ID
响应
状态:200
{ "id": 80, "node_id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=", "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 }, "body": "Here is the body for the review.", "state": "APPROVED", "html_url": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80", "pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/12", "_links": { "html": { "href": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80" }, "pull_request": { "href": "https://api.github.com/repos/octocat/Hello-World/pulls/12" } }, "submitted_at": "2019-11-17T17:43:43Z", "commit_id": "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091", "author_association": "COLLABORATOR" }
更新拉取请求评审
更新指定评审摘要评论的内容。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github-commitcomment.raw+json
: 返回原始 Markdown 正文。响应将包含body
。如果未传递任何特定媒体类型,则为默认值。application/vnd.github-commitcomment.text+json
: 返回 Markdown 正文的纯文本表示形式。响应将包含body_text
。application/vnd.github-commitcomment.html+json
: 返回从正文的 Markdown 渲染的 HTML。响应将包含body_html
。application/vnd.github-commitcomment.full+json
: 返回原始、文本和 HTML 表示形式。响应将包含body
、body_text
和body_html
。
用于“更新拉取请求评审”的细粒度访问令牌
此端点与以下细粒度令牌类型一起使用
细粒度令牌必须具有以下权限集
- “拉取请求”存储库权限(写入)
“更新拉取请求评审”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
owner string 必需存储库的帐户所有者。名称不区分大小写。 |
repo string 必需存储库的名称,不含 |
pull_number integer 必需标识拉取请求的编号。 |
review_id 整数 必需评审的唯一标识符。 |
名称、类型、描述 |
---|
body 字符串 必填拉取请求评审的正文文本。 |
“更新拉取请求评审”的 HTTP 响应状态代码
状态码 | 描述 |
---|---|
200 | OK |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
“更新拉取请求评审”的代码示例
请求示例
curl -L \ -X PUT \ -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/pulls/PULL_NUMBER/reviews/REVIEW_ID \ -d '{"body":"这已经很完美了!请解决建议的内联更改。并添加更多关于此的信息。"}'
响应
状态:200
{ "id": 80, "node_id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=", "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 }, "body": "这已经很完美了!请解决建议的内联更改。并添加更多关于此的信息。", "state": "CHANGES_REQUESTED", "html_url": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80", "pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/12", "_links": { "html": { "href": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80" }, "pull_request": { "href": "https://api.github.com/repos/octocat/Hello-World/pulls/12" } }, "submitted_at": "2019-11-17T17:43:43Z", "commit_id": "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091", "author_association": "COLLABORATOR" }
删除拉取请求的待处理评审
删除尚未提交的拉取请求评审。已提交的评审无法删除。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github-commitcomment.raw+json
: 返回原始 Markdown 正文。响应将包含body
。如果未传递任何特定媒体类型,则为默认值。application/vnd.github-commitcomment.text+json
: 返回 Markdown 正文的纯文本表示形式。响应将包含body_text
。application/vnd.github-commitcomment.html+json
: 返回从正文的 Markdown 渲染的 HTML。响应将包含body_html
。application/vnd.github-commitcomment.full+json
: 返回原始、文本和 HTML 表示形式。响应将包含body
、body_text
和body_html
。
用于“删除拉取请求的待处理评审”的细粒度访问令牌
此端点与以下细粒度令牌类型一起使用
细粒度令牌必须具有以下权限集
- “拉取请求”存储库权限(写入)
用于“删除拉取请求的待处理评审”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
owner string 必需存储库的帐户所有者。名称不区分大小写。 |
repo string 必需存储库的名称,不含 |
pull_number integer 必需标识拉取请求的编号。 |
review_id 整数 必需评审的唯一标识符。 |
用于“删除拉取请求的待处理评审”的 HTTP 响应状态代码
状态码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
用于“删除拉取请求的待处理评审”的代码示例
请求示例
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/pulls/PULL_NUMBER/reviews/REVIEW_ID
响应
状态:200
{ "id": 80, "node_id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=", "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 }, "body": "This is close to perfect! Please address the suggested inline change.", "state": "CHANGES_REQUESTED", "html_url": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80", "pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/12", "_links": { "html": { "href": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80" }, "pull_request": { "href": "https://api.github.com/repos/octocat/Hello-World/pulls/12" } }, "submitted_at": "2019-11-17T17:43:43Z", "commit_id": "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091", "author_association": "COLLABORATOR" }
列出拉取请求评审的评论
列出特定拉取请求评审的评论。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github-commitcomment.raw+json
: 返回原始 Markdown 正文。响应将包含body
。如果未传递任何特定媒体类型,则为默认值。application/vnd.github-commitcomment.text+json
: 返回 Markdown 正文的纯文本表示形式。响应将包含body_text
。application/vnd.github-commitcomment.html+json
: 返回从正文的 Markdown 渲染的 HTML。响应将包含body_html
。application/vnd.github-commitcomment.full+json
: 返回原始、文本和 HTML 表示形式。响应将包含body
、body_text
和body_html
。
针对“列出拉取请求评审的评论”的细粒度访问令牌
此端点与以下细粒度令牌类型一起使用
细粒度令牌必须具有以下权限集
- “拉取请求”存储库权限(读取)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。
“列出拉取请求评审的评论”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
owner string 必需存储库的帐户所有者。名称不区分大小写。 |
repo string 必需存储库的名称,不含 |
pull_number integer 必需标识拉取请求的编号。 |
review_id 整数 必需评审的唯一标识符。 |
名称、类型、描述 |
---|
per_page integer 每页结果数(最大 100)。有关更多信息,请参阅 "在 REST API 中使用分页." 默认: |
page 整数 要获取的结果页码。有关更多信息,请参阅“在 REST API 中使用分页”。 默认: |
“列出拉取请求评审的评论”的 HTTP 响应状态码
状态码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
“列出拉取请求评审的评论”的代码示例
请求示例
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/pulls/PULL_NUMBER/reviews/REVIEW_ID/comments
响应
状态:200
[ { "url": "https://api.github.com/repos/octocat/Hello-World/pulls/comments/1", "pull_request_review_id": 42, "id": 10, "node_id": "MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDEw", "diff_hunk": "@@ -16,33 +16,40 @@ public class Connection : IConnection...", "path": "file1.txt", "position": 1, "original_position": 4, "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e", "original_commit_id": "9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840", "in_reply_to_id": 8, "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 }, "body": "Great stuff!", "created_at": "2011-04-14T16:00:49Z", "updated_at": "2011-04-14T16:00:49Z", "html_url": "https://github.com/octocat/Hello-World/pull/1#discussion-diff-1", "pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1", "author_association": "NONE", "_links": { "self": { "href": "https://api.github.com/repos/octocat/Hello-World/pulls/comments/1" }, "html": { "href": "https://github.com/octocat/Hello-World/pull/1#discussion-diff-1" }, "pull_request": { "href": "https://api.github.com/repos/octocat/Hello-World/pulls/1" } } } ]
驳回拉取请求的评审
驳回拉取请求上的指定评审。
注意: 要驳回受保护分支上的拉取请求审查,您必须是存储库管理员,或包含在可以驳回拉取请求审查的人员或团队列表中。有关受保护分支的更多信息,请参阅 受保护分支。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github-commitcomment.raw+json
: 返回原始 Markdown 正文。响应将包含body
。如果未传递任何特定媒体类型,则为默认值。application/vnd.github-commitcomment.text+json
: 返回 Markdown 正文的纯文本表示形式。响应将包含body_text
。application/vnd.github-commitcomment.html+json
: 返回从正文的 Markdown 渲染的 HTML。响应将包含body_html
。application/vnd.github-commitcomment.full+json
: 返回原始、文本和 HTML 表示形式。响应将包含body
、body_text
和body_html
。
“驳回拉取请求审查”的细粒度访问令牌
此端点与以下细粒度令牌类型一起使用
细粒度令牌必须具有以下权限集
- “拉取请求”存储库权限(写入)
“驳回拉取请求审查”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
owner string 必需存储库的帐户所有者。名称不区分大小写。 |
repo string 必需存储库的名称,不含 |
pull_number integer 必需标识拉取请求的编号。 |
review_id 整数 必需评审的唯一标识符。 |
名称、类型、描述 |
---|
message string 必需驳回拉取请求审查的消息 |
event string 值: |
“驳回拉取请求审查”的 HTTP 响应状态代码
状态码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
“驳回拉取请求审查”的代码示例
请求示例
curl -L \ -X PUT \ -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/pulls/PULL_NUMBER/reviews/REVIEW_ID/dismissals \ -d '{"message":"You are dismissed","event":"DISMISS"}'
响应
状态:200
{ "id": 80, "node_id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=", "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 }, "body": "Here is the body for the review.", "state": "DISMISSED", "html_url": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80", "pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/12", "_links": { "html": { "href": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80" }, "pull_request": { "href": "https://api.github.com/repos/octocat/Hello-World/pulls/12" } }, "submitted_at": "2019-11-17T17:43:43Z", "commit_id": "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091", "author_association": "COLLABORATOR" }
提交拉取请求审查
提交拉取请求的待处理审查。有关为拉取请求创建待处理审查的更多信息,请参阅 "为拉取请求创建审查。"。
此端点支持以下自定义媒体类型。有关更多信息,请参阅 "媒体类型."
application/vnd.github-commitcomment.raw+json
: 返回原始 Markdown 正文。响应将包含body
。如果未传递任何特定媒体类型,则为默认值。application/vnd.github-commitcomment.text+json
: 返回 Markdown 正文的纯文本表示形式。响应将包含body_text
。application/vnd.github-commitcomment.html+json
: 返回从正文的 Markdown 渲染的 HTML。响应将包含body_html
。application/vnd.github-commitcomment.full+json
: 返回原始、文本和 HTML 表示形式。响应将包含body
、body_text
和body_html
。
“提交拉取请求审查”的细粒度访问令牌
此端点与以下细粒度令牌类型一起使用
细粒度令牌必须具有以下权限集
- “拉取请求”存储库权限(写入)
“提交拉取请求审查”的参数
名称、类型、描述 |
---|
accept string 建议设置为 |
名称、类型、描述 |
---|
owner string 必需存储库的帐户所有者。名称不区分大小写。 |
repo string 必需存储库的名称,不含 |
pull_number integer 必需标识拉取请求的编号。 |
review_id 整数 必需评审的唯一标识符。 |
名称、类型、描述 |
---|
body string 拉取请求审查的正文文本 |
event string 必需您要执行的评审操作。评审操作包括: 可以是以下之一: |
“提交拉取请求评审”的 HTTP 响应状态代码
状态码 | 描述 |
---|---|
200 | OK |
403 | 禁止 |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
“提交拉取请求评审”的代码示例
请求示例
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/pulls/PULL_NUMBER/reviews/REVIEW_ID/events \ -d '{"body":"Here is the body for the review.","event":"REQUEST_CHANGES"}'
响应
状态:200
{ "id": 80, "node_id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=", "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 }, "body": "Here is the body for the review.", "state": "APPROVED", "html_url": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80", "pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/12", "_links": { "html": { "href": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80" }, "pull_request": { "href": "https://api.github.com/repos/octocat/Hello-World/pulls/12" } }, "submitted_at": "2019-11-17T17:43:43Z", "commit_id": "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091", "author_association": "COLLABORATOR" }