添加Issue或者Pull Request到看板¶
POST /api/v5/org/{owner}/kanban/{kanban_id}/add_item
该接口用于将指定仓库中的 Issue 和 Pull Request 添加到指定组织的看板中,通过提交仓库路径及 Issue、Pull Request 的编号列表,即可将相应条目纳入看板进行管理。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 组织的路径 |
kanban_id |
path | string | 是 | 看板id |
Request Body:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"repo": {
"description": "仓库的路径",
"type": "string"
},
"issue_iids": {
"description": "仓库内issue的iid",
"type": "array",
"items": {
"type": "integer"
}
},
"pr_iids": {
"description": "仓库内pull request的iid",
"type": "array",
"items": {
"type": "integer"
}
}
},
"required": ["repo", "issue_iids", "pr_iids"]
}
响应参数¶
接口成功时响应体为空对象 {},不返回业务字段。
失败响应¶
400 参数错误
401 未认证
错误字段名以后端实际返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad request) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
资源不存在(Not found) |
500 |
系统内部错误(Internal server error) |
请求示例¶
参数说明¶
本接口允许匿名访问;如需认证,可携带 AtomGit 用户访问令牌。
<owner>替换为组织的路径(企业、组织或个人的地址 path);<kanban_id>替换为看板 id;<repo>替换为仓库的路径。
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/org/<owner>/kanban/<kanban_id>/add_item' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"repo": "<repo>", "issue_iids": [1, 2], "pr_iids": [3]}'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/org/<owner>/kanban/<kanban_id>/add_item", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
},
body: JSON.stringify({
repo: "<repo>",
issue_iids: [1, 2],
pr_iids: [3]
})
});
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/org/<owner>/kanban/<kanban_id>/add_item",
json={
"repo": "<repo>",
"issue_iids": [1, 2],
"pr_iids": [3],
},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效 |
403 |
禁止访问 |
404 |
请求路径不存在 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc