元数据
获取实体列表
- API 地址:
metadata/entity - HTTP 方法:GET
- 授权方式:通用授权
请求参数
| 参数 | 类型 | 是否必须 | 参数说明 |
|---|---|---|---|
| type | int | 否 | 实体类型,默认为 0 返回全部,0 = 全部,1 = 系统实体,2 = 自定义实体 |
返回数据示例
{
"error_code": 0,
"error_msg": "调用成功",
"data": [{
"code" 2,
"entity": "Account",
"name": "客户",
"type": 1,
"name_field": "accountName"
}, {
"code": 3,
"entity": "Contact",
"name": "联系人",
"type": 1,
"name_field": "contactName"
}]
}
返回数据说明
| 字段 | 类型 | 字段说明 |
|---|---|---|
| code | int(3) | 实体代码,如客户的实体代码为 2 |
| entity | string | 实体的内部名称 |
| name | string | 实体的显示名称 |
| type | int | 实体类型,1 = 系统实体,2 = 自定义实体 |
| name_field | string | 主显字段 |
获取实体字段列表
- API 地址:
metadata/field - HTTP 方法:GET
- 授权方式:通用授权
请求参数
| 参数 | 类型 | 是否必须 | 参数说明 |
|---|---|---|---|
| type | int | 否 | 字段类型,默认为 0 返回全部,0 = 全部,1 = 系统字段,2 = 自定义字段 |
| entity | string | 是 | 实体内部名称,即要获取哪个实体的字段 |
返回数据示例
{
"error_code": 0,
"error_msg": "调用成功",
"data": [{
"field": "accountName",
"name": "客户名称",
"type": 1,
"data_type": "string",
"nullable": false,
"creatable": true,
"updatable": true
}, {
"field": "owning_user",
"name": "所属用户",
"type": 1,
"data_type": "reference",
"reference_to": "User",
"nullable": false,
"creatable": true,
"updatable": true
}]
}
返回数据说明
| 字段 | 类型 | 字段说明 |
|---|---|---|
| entity | string | 实体内部名称 |
| name | string | 实体显示名称 |
| type | int | 实体类型,1 = 系统实体,2 = 自定义实体 |
| data_type | string | 字段的数据类型 |
| nullable | boolean | 是否允许为空值 |
| creatable | boolean | 是否可以在创建时指定值(不可创建的值通常用于自动填充类字段,例如记录ID应该由系统自动生成而非自己指定) |
| updatable | boolean | 是否可以更新此字段的值。注意:在使用 */update 接口时,如传入此类字段将会被忽略 |
| reference_to | string | 仅在数据类型为 reference 时有效,意为此字段关联的实体 |
工具
我们编写了一个 元数据获取工具,你可以直接使用。