Request method: POST.
Service URL/v3/device/set_custom_attribute
API service URLs correspond to service access points one by one. Please select the service URL corresponding to the service access point of your application.
Feature: this API is used to manage personalized attributes at the token level, including creation, deletion, update, and query operations.
Parameter | Required | Type | Description |
---|---|---|---|
cmd | Yes | Integer | Operation type: |
token | Yes | String | Unique ID assigned to each device by TPNS. |
attributeInfo | Yes (when cmd is 1 , 2 , or 3 ) |
Map | Attribute details. See the description of the attributeMap parameter below. |
attributeMap | Yes (when cmd is 1 , 2 , or 3 ) |
Map | Attribute details: key indicates the attribute name and can contain up to 50 bytes. Note: you should have created an attribute in the TPNS console > Toolbox > User Attribute Management; otherwise, this parameter will be filtered out, and invalidAttribute will be returned. value indicates the attribute value and can contain up to 50 bytes. |
Parameter | Returned | Type | Description |
---|---|---|---|
retCode | Yes | Integer | Error code. For more information, please see Server-Side Error Codes. |
errMsg | Yes | String | Error message when an error occurs in the request. |
attributeInfo | Yes (when cmd is 5 ) |
Map | Attribute details. |
invalidAttribute | Yes (when the attribute is invalid) | Array | Details of the invalid attribute. |
Add three attributes to a token.
{
"cmd": 1,
"token": "04cac74a714f61bf089987a986363d88****",
"attributeInfo": {
"attributeMap": {
"age": "100",
"name": "Ming",
"high": "2.66"
}
}
}
{
"retCode": 0,
"errMsg": "success",
"invalidAttribute": [
"high" // The corresponding key value does not exist in the console
]
}
Update the value of the name
attribute to workman
.
{
"cmd": 2,
"token": "04cac74a714f61bf089987a986363d88****",
"attributeInfo": {
"attributeMap": {
"name": "workman"
}
}
}
{
"retCode": 0,
"errMsg": "success"
}
Delete the workman
value of the name
attribute.
{
"cmd": 3,
"token": "04cac74a714f61bf089987a986363d88****",
"attributeInfo": {
"attributeMap": {
"name": "workman"
}
}
}
{
"retCode": 0,
"errMsg": "success"
}
Delete all attributes of a token.
{
"cmd": 4,
"token": "04cac74a714f61bf089987a986363d88****"
}
{
"retCode": 0,
"errMsg": "success"
}
Query the attribute details of a token.
{
"cmd": 5,
"token": "04cac74a714f61bf089987a986363d88****"
}
{
"retCode": 0,
"errMsg": "success",
"attributeInfo": {
"attributeMap": {
"nickname": "workman"
}
}
}
Was this page helpful?