请求方式:POST。
服务地址/v3/device/set_custom_attribute
接口服务地址与服务接入点一一对应,请选择与您的应用服务接入点对应的 服务地址。
接口功能:用于 token 级别的个性化属性配置,包括增加、删除、更新、查询功能。
参数名称 | 是否必填 | 类型 | 描述 |
---|---|---|---|
cmd | 是 | Integer | 操作类型: |
token | 是 | String | TPNS 为设备分配的唯一 ID |
attributeInfo | 当 cmd=1,2,3时必填 | Map | 属性详情,参考下方 attributeMap 描述 |
attributeMap | 当 cmd=1,2,3时必填 | Map | 属性详情: 注意:需要已经在【控制台】>【配置管理】>【用户属性管理】中创建属性,否则会被过滤掉,并返回 invalidAttribute。 |
参数名称 | 是否必定返回 | 类型 | 描述 |
---|---|---|---|
retCode | 是 | Integer | 错误码,详细参照 错误码对照表 。 |
errMsg | 是 | String | 请求出错时的错误信息。 |
attributeInfo | cmd = 5 | Map | 属性详情。 |
invalidAttribute | 属性无效时 | Array | 无效属性详情。 |
为单个 token 增加3个属性。
{
"cmd": 1,
"token": "04cac74a714f61bf089987a986363d88****",
"attributeInfo": {
"attributeMap": {
"age": "100",
"name": "Ming",
"high": "2.66"
}
}
}
{
"retCode": 0,
"errMsg": "success",
"invalidAttribute": [
"high" // 控制台上没有对应的 key 值
]
}
更新属性“name”对应的值“workman”。
{
"cmd": 2,
"token": "04cac74a714f61bf089987a986363d88****",
"attributeInfo": {
"attributeMap": {
"name": "workman"
}
}
}
{
"retCode": 0,
"errMsg": "success"
}
删除属性“name”对应的值“workman”。
{
"cmd": 3,
"token": "04cac74a714f61bf089987a986363d88****",
"attributeInfo": {
"attributeMap": {
"name": "workman"
}
}
}
{
"retCode": 0,
"errMsg": "success"
}
删除该 token 下的所有属性。
{
"cmd": 4,
"token": "04cac74a714f61bf089987a986363d88****"
}
{
"retCode": 0,
"errMsg": "success"
}
查询该 token 下的属性详情。
{
"cmd": 5,
"token": "04cac74a714f61bf089987a986363d88****"
}
{
"retCode": 0,
"errMsg": "success",
"attributeInfo": {
"attributeMap": {
"nickname": "workman"
}
}
}
本页内容是否解决了您的问题?