Write Resources

IMPACT sends a write JSON request using http POST to /devices in the following format. When the write request is sent, the Device responds with http status 200 OK. POST the write command, status is sent asynchronously to /m2m/device.

The expected response for this write request is shown below. If correlatorId is found in the write command then the same token along with its value must be sent back in the response. The usage of requestStatus and responseCode is explained in the Read Resources section.

Table 1. Write resources API format
Parameters Description
URL http://<adapter_hostname>:<port>/devices
Method POST
Content-Type application/json
Parameters

The parameters are:

  • correlatorId - Specifies a unique identification generated by IMPACT to identify the command.
  • endPointClientNames - Specifies an array of Device serial numbers.
  • resources - Specifies an array of Device resources on which Write operation is to be performed.
Sample Call
{
	“correlatorId”:”the correlator value”
                "write":[
                                {
                                    "resources":"device/0/battery",
                                    "endPointClientNames":["TTo1AZliuT"],
			“string”:”some value”,
                                },
                                {
                                    "resources":"device/0/firmware",
                                    "endPointClientNames":["TTo1AZliuT","asdfgh"],
			“string”:”another value”
                                }
                ]
}

Response Body:

{
	“correlatorId”:”the correlator value”
          "writeResponse": 
            {
		   “requestStatus”:0,
		   “responseCode”:0,
             }
}
}
Success Code
Response Code: 200
Error Code
400 : Bad Request
401 : Unauthorized 
403 : Forbidden 
404 : Not Found