更新授权用户所管理的组织资料¶
PATCH /api/v5/orgs/{org}
该接口用于更新授权用户所管理的组织资料,可修改组织的名称、公开邮箱、所在地、简介及站点等信息。通过这个接口,用户可以保持组织资料的准确与最新。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
org |
path | string | 是 | 组织的路径(path/login) |
access_token |
query | string | 是 | 用户授权码 |
Request Body:
请求体为可选的 JSON 对象,所有字段均为可选项。
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"description": "组织名称",
"type": "string"
},
"email": {
"description": "组织公开的邮箱地址",
"type": "string"
},
"location": {
"description": "组织所在地",
"type": "string"
},
"description": {
"description": "组织简介",
"type": "string"
},
"html_url": {
"description": "组织站点",
"type": "string"
}
},
"required": []
}
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
email |
string | 是 | 否 | 组织公开的邮箱地址 |
name |
string | 是 | 否 | 组织名称 |
description |
string | 是 | 否 | 组织简介 |
html_url |
string | 是 | 否 | 组织站点 |
id |
integer | 是 | 否 | 组织 ID |
path |
string | 是 | 否 | 组织的路径(path/login) |
失败响应¶
400 参数错误
401 未认证
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
304 |
未修改(Not modified) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
请求示例¶
参数说明¶
<org>替换为组织路径名(企业、组织或个人的地址 path);<token>替换为你的 AtomGit 用户访问令牌。
cURL¶
curl -X PATCH 'https://api.atomgit.com/api/v5/orgs/<org>?access_token=<token>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"name": "组织",
"email": "123@qq.com",
"location": "北京",
"description": "233333",
"html_url": "www.baidu.com"
}'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/orgs/<org>?access_token=<token>", {
method: "PATCH",
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "组织",
email: "123@qq.com",
location: "北京",
description: "233333",
html_url: "www.baidu.com",
}),
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.patch(
"https://api.atomgit.com/api/v5/orgs/<org>",
params={"access_token": "<token>"},
headers={
"Accept": "application/json",
"Content-Type": "application/json",
},
json={
"name": "组织",
"email": "123@qq.com",
"location": "北京",
"description": "233333",
"html_url": "www.baidu.com",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"email": "123@qq.com",
"name": "组织",
"description": "233333",
"html_url": "www.baidu.com",
"id": 138108,
"path": "xiaogang444"
}
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
400 |
参数错误或请求无法解析 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc