子码内容
读取批量模板下某个子码的元信息与各字段的实际内容——即「一码一档」里这一档的具体数据。
请求示例
python
import requests
url = "https://open.cli.im/api/v2/rpc/templates/getSubcode"
data = {"template": "tA9kQ2f", "subcode": "sK2mP9a"}
headers = {
"Authorization": "Bearer <你的API Key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=data, headers=headers)
print(response.text)bash
curl -X POST 'https://open.cli.im/api/v2/rpc/templates/getSubcode' \
-H 'Authorization: Bearer <你的API Key>' \
-H 'Content-Type: application/json' \
-d '{"template": "tA9kQ2f", "subcode": "sK2mP9a"}'请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
template | string | 是 | 占位码 coding 或完整 URL |
subcode | string | 是 | 子码 coding 或完整 URL,从 模板下子码列表 获取 |
注:子码必须属于该模板,否则按不存在处理(返回 404)。
完整返回示例
json
{
"code": 0,
"message": "ok",
"data": {
"meta": {
"title": "1号灭火器",
"url": "https://qr61.cn/xxxx/zzz",
"coding": "sK2mP9a"
},
"fields": [
{ "field_id": 71399639089153, "type": "text", "title": "设备编号", "value": "MHQ-001" },
{ "field_id": 71399639089158, "type": "text", "title": "安装位置", "value": "一号楼东侧楼梯间" }
]
}
}响应结构
| 路径 | 类型 | 说明 |
|---|---|---|
data.meta.title | string | 子码名称 |
data.meta.url | string | 子码访问 URL |
data.meta.coding | string | 子码 coding |
data.fields[].field_id | integer | 字段 ID,与 批量模板结构 的字段一一对应 |
data.fields[].type | string | 字段类型 |
data.fields[].title | string | 字段标题 |
data.fields[].value | string | 该子码在此字段下的实际内容 |
错误响应
占位码或子码不存在、子码不属于该模板、无权限时返回 404:
json
{
"code": 404,
"message": "Subcode not found or access denied",
"data": {}
}其余错误码定义见:错误码说明。