编辑元数据字段
编辑元数据字段
批量编辑元数据字段。仅可修改 display_label、description、ai_search_filter——传了才改,不传保持原样。一次最多编辑 50 个。
批量规则:
一次最多编辑 50 个,超过 50 整批不处理。
请求内 id 重复:仅保留第一组,其余标记失败。
请求方式
PUT
调用地址
https://api-${endpoint}.gptbots.ai/v1/bot/doc/metadata/field/update
调用验证
详情参见 API 概述的鉴权方式说明。
请求
请求示例
curl -X PUT 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/metadata/field/update' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"fields": [
{
"id": "665f1c8a9b2e4d001a3f0001",
"display_label": "文档分类",
"description": "文档所属的业务分类",
"ai_search_filter": false
}
]
}'
curl -X PUT 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/metadata/field/update' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"fields": [
{
"id": "665f1c8a9b2e4d001a3f0001",
"display_label": "文档分类",
"description": "文档所属的业务分类",
"ai_search_filter": false
}
]
}'
此代码块在浮窗中显示
请求头
| 字段 | 类型 | 描述 |
|---|---|---|
| Authorization | Bearer ${API Key} | 使用 Authorization: Bearer ${API Key}进行调用验证,请在 API 密钥页面获取密钥作为 API Key。 |
| Content-Type | application/json | 数据类型,设置为 application/json。 |
请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| fields | Array<Object> | 是 | 要编辑的字段列表,一次最多 50 个。 |
| id | String | 是 | 元数据字段 ID,用于定位字段。 |
| display_label | String | 否 | 新展示名,最长 64。传了才改,唯一。 |
| description | String | 否 | 新字段说明,最长 50。传了才改。 |
| ai_search_filter | Boolean | 否 | 新的 AI Search 筛选开关。传了才改。 |
响应
响应示例
{
"success_count": 1,
"failure_count": 2,
"results": [
{
"id": "665f1c8a9b2e4d001a3f0001",
"success": true
},
{
"id": "665f1c8a9b2e4d001a3f0002",
"success": false,
"error_message": "display_label already exists"
},
{
"id": "665f1c8a9b2e4d001a3f0001",
"success": false,
"error_message": "duplicate id in request"
}
]
}
{
"success_count": 1,
"failure_count": 2,
"results": [
{
"id": "665f1c8a9b2e4d001a3f0001",
"success": true
},
{
"id": "665f1c8a9b2e4d001a3f0002",
"success": false,
"error_message": "display_label already exists"
},
{
"id": "665f1c8a9b2e4d001a3f0001",
"success": false,
"error_message": "duplicate id in request"
}
]
}
此代码块在浮窗中显示
成功响应
| 字段 | 类型 | 说明 |
|---|---|---|
| success_count | Integer | 编辑成功的字段数。 |
| failure_count | Integer | 编辑失败的字段数。 |
| results | Array<Object> | 逐字段结果,按请求顺序返回。 |
| id | String | 字段 ID。 |
| success | Boolean | 是否编辑成功。 |
| error_message | String | 失败原因:display_label already exists(展示名与已有冲突) / duplicate id in request(请求内 id 重复) / field not found(字段不存在)。 |
失败响应
| 字段 | 类型 | 描述 |
|---|---|---|
| code | Integer | 错误码。 |
| message | String | 错误详情。 |
