批量模板结构
根据占位码 coding 或 URL,获取批量模板的元信息与字段结构。字段结构告诉你这个模板下每个子码有哪些内容字段——读取或生成子码内容前先看它。
请求示例
python
import requests
url = "https://open.cli.im/api/v2/rpc/templates/get"
data = {"template": "tA9kQ2f"}
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/get' \
-H 'Authorization: Bearer <你的API Key>' \
-H 'Content-Type: application/json' \
-d '{"template": "tA9kQ2f"}'请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
template | string | 是 | 占位码 coding 或完整 URL,从 批量模板列表 获取 |
完整返回示例
json
{
"code": 0,
"message": "ok",
"data": {
"meta": {
"title": "设备档案",
"url": "https://qr61.cn/xxxx/yyy",
"coding": "tA9kQ2f"
},
"fields": [
{ "field_id": 71399639089153, "type": "text", "title": "设备编号", "value": "" },
{ "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 | 字段类型(text、image 等) |
data.fields[].title | string | 字段标题(用户在模板里起的名字) |
data.fields[].value | string | 模板层的默认值;子码各自的值见 子码内容 |
错误响应
占位码不存在或无权限时返回 404:
json
{
"code": 404,
"message": "Template not found or access denied",
"data": {}
}其余错误码定义见:错误码说明。