获取企业某个Issue所有评论¶
GET /api/v5/enterprises/{enterprise}/issues/{number}/comments
该接口用于获取指定企业下某个 Issue 的全部评论,支持分页查询。返回结果包含每条评论的内容、创建及更新时间、评论关联的 Issue 信息,以及发表评论的用户信息。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
enterprise |
path | string | 是 | 仓库所属空间地址(组织或个人的地址path) |
number |
path | integer | 是 | issue 全局唯一 id |
page |
query | integer | 否 | 当前的页码 |
per_page |
query | integer | 否 | 每页的数量:最大为 100,默认 20 |
响应参数¶
响应体为评论对象数组,每个数组元素包含评论内容、评论关联的 issue 以及发表评论的用户信息。
comment 对象(数组元素)
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
comment.body |
string | 是 | — | 评论内容 |
comment.created_at |
string | 是 | — | 评论创建时间 |
comment.id |
integer | 是 | — | 评论 ID |
comment.target |
object | 是 | — | 评论目标对象 |
comment.updated_at |
string | 是 | — | 评论更新时间 |
comment.user |
object | 是 | — | 发表评论的用户信息 |
comment.target 对象¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
comment.target.issue |
object | 是 | — | 评论关联的 issue 信息 |
comment.target.issue 对象¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
comment.target.issue.id |
integer | 是 | — | issue 全局唯一 id |
comment.target.issue.iid |
integer | 是 | — | issue 在所属空间内的编号 |
comment.target.issue.title |
string | 是 | — | issue 标题 |
comment.user 对象¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
comment.user.id |
integer | 是 | — | 用户 ID |
comment.user.login |
string | 是 | — | 用户登录名 |
comment.user.name |
string | 是 | — | 用户昵称 |
comment.user.type |
string | 是 | — | 用户类型,如 User |
失败响应¶
该接口在参数错误或资源不存在时返回失败响应,错误字段名以后端实际返回为准。
400 参数错误
404 资源不存在
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad Request) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
资源不存在(Not Found) |
请求示例¶
参数说明¶
<enterprise>替换为企业/组织的地址 path(仓库所属空间地址);<number>替换为 issue 的全局唯一 id。 本接口允许匿名访问,也可携带access_token查询参数进行认证。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/enterprises/<enterprise>/issues/<number>/comments?page=1&per_page=20' -H 'Accept: application/json'
JavaScript¶
const response = await fetch("https://api.atomgit.com/api/v5/enterprises/<enterprise>/issues/<number>/comments?page=1&per_page=20", {
headers: {
"Accept": "application/json",
},
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.get(
"https://api.atomgit.com/api/v5/enterprises/<enterprise>/issues/<number>/comments",
params={"page": 1, "per_page": 20},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
[
{
"body": "etst",
"created_at": "2024-12-10T16:02:21+08:00",
"id": 1535981,
"target": {
"issue": {
"id": 471521,
"iid": 1,
"title": "bbbbb"
}
},
"updated_at": "2024-12-10T16:02:21+08:00",
"user": {
"id": 287,
"login": "csdn_fenglh",
"name": "fenglh",
"type": "User"
}
}
]
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效 |
403 |
禁止访问 |
404 |
请求路径不存在或资源不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc