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. Unique identifier of each instance in the physical multi-tenant scenario. Mandatory for professional editions and recommended in other cases. Log in to the IoTDA console and choose Overview in the navigation pane to view the instance ID. For details, see Viewing Instance Details. |
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. [{"service_id": "Temperature","properties": {"value": 57}},{"service_id": "Battery","properties": {"level": 80}}] is an example. The specific format is determined by the application and device. The maximum length is 256 KB. Maximum: 262144 |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
request_id |
String |
An ID that uniquely identifies a device property update request. It is unique and is allocated by the platform when delivering a command for device property update. |
response |
Object |
Property execution result reported by the device. The value is in JSON format. The specific format depends on the application and device. |
error_code |
String |
Error code of a property update exception. |
error_msg |
String |
Error message of a property update exception. |
Example Requests
Delivers device properties. The property of the Temperature service is value and the value is 57. The property of the Batter service is level and the value is 80.
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
{ "request_id" : "b1224afb-e9f0-4916-8220-b6bab568e888", "response" : { "result_code" : 0, "result_desc" : "success" } }
Status Codes
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
401 |
Unauthorized |
403 |
Forbidden |
404 |
Not Found |
500 |
Internal Server Error |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot