Modify Device Properties
Function
A product model defines properties that the platform can deliver to devices. This API is used by an application to deliver properties to a specific device. The platform sends the properties to the device in synchronous mode and returns the execution result synchronously to the application. This API can only be used for MQTT devices. NB-IoT devices are not supported.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
URI
PUT /v5/iot/{project_id}/devices/{device_id}/properties
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
device_id |
Yes |
String |
Parameter description: ID of the device to which the property is delivered. The ID is unique and is allocated by the platform during device registration. Value: The value can contain a maximum of 128 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. |
project_id |
Yes |
String |
Parameter description: project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
No |
String |
Parameter description: user token. You can obtain the token by calling the IAM API Obtaining a User Token Through Password Authentication. In the returned response header, X-Subject-Token is the desired user token. For details about how to obtain the token, see Token Authentication. |
Instance-Id |
No |
String |
Parameter description: instance ID. This parameter is required only when the API is called from the management plane in the physical multi-tenant scenario. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
services |
No |
Object |
Parameter description: properties that will be modified. The value is in JSON format (key-value pairs). If service_id is specified, each key is a paraName of a property in the product model. If service_id is left empty, custom property format is used, for example, [{"service_id": "Temperature","properties": {"value": 57}},{"service_id": "Battery","properties": {"level": 80}}]. The specific format is determined by the application and device. Maximum: 2048 |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
response |
Object |
Property execution result reported by the device. The value is in JSON format. The specific format depends on the application and device. |
Example Requests
PUT https://{endpoint}/v5/iot/{project_id}/devices/{device_id}/properties { "services" : [ { "service_id" : "Temperature", "properties" : { "value" : 57 } }, { "service_id" : "Battery", "properties" : { "level" : 80 } } ] }
Example Responses
Status code: 200
OK
{ "response" : { "result_code" : 0, "result_desc" : "success" } }
Status Codes
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
403 |
Forbidden |
404 |
Not Found |
500 |
Internal Server Error |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackFor any further questions, feel free to contact us through the chatbot.
Chatbot