回复Pull Request评论¶
POST /api/v5/repos/{owner}/{repo}/pulls/{number}/discussions/{discussion_id}/comments
该接口用于对指定 Pull Request 讨论中的评论进行回复,提交回复正文后,该回复会作为一条新评论写入对应讨论,并返回评论编号及正文内容。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(组织或个人的地址 path) |
repo |
path | string | 是 | 仓库路径(path) |
number |
path | integer | 是 | 第几个 PR,即本仓库 PR 的序数 |
discussion_id |
path | string | 是 | 讨论 id |
Request Body:
请求体为回复评论的内容,携带 body 字段。
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"body": {
"description": "回复评论的正文内容",
"type": "string"
}
},
"required": ["body"]
}
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
string | 是 | 否 | 讨论 id |
noteId |
integer | 是 | 否 | 评论 id |
body |
string | 是 | 否 | 回复的评论正文内容 |
失败响应¶
该接口可能返回如下失败状态码。错误响应体的具体字段名以后端实际返回为准。
400 参数错误
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad Request) |
401 |
需要认证(Unauthorized) |
403 |
禁止访问(Forbidden) |
404 |
请求路径不存在(Not Found) |
429 |
请求过于频繁,触发限流(Too Many Requests) |
500 |
系统内部错误(Internal Server Error) |
请求示例¶
参数说明¶
示例必须与本文档其余部分自洽,照抄即可调用成功。
- 本接口允许匿名访问,示例未携带访问令牌;如需认证,可携带 AtomGit 用户访问令牌。
<owner>替换为仓库所属空间地址(组织或个人的地址 path);<repo>替换为仓库路径(path);<number>替换为 PR 序号(第几个 PR);<discussion_id>替换为讨论 id。
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/discussions/<discussion_id>/comments' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"body": "感谢反馈,已修复该问题"}'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/discussions/<discussion_id>/comments",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
body: "感谢反馈,已修复该问题",
}),
}
);
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.post(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/discussions/<discussion_id>/comments",
headers={
"Content-Type": "application/json",
"Accept": "application/json",
},
json={"body": "感谢反馈,已修复该问题"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
400 |
参数错误或请求无法解析 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc