Invoke POST Method on a Device

post

/iot/api/v2/apps/{app-id}/devices/{device-id}/resources/{subResources}

Does the specified resource invocation by forwarding the request to the specified endpoint and providing a response sent by it and received back by the server. The handler of the resource optionally receives request's body that may contain data of an arbitrary type. Invocation may take a significant time to complete depending on connectivity of an endpoint; the messages that carry request and response data may stay pending on both sides waiting for a chance to be delivered for minutes, hours, or days.

There are two invocation modes supported by this interface: synchronous and asynchronous. With synchronous request the server does not reply until a response gets received from the endpoint or a timeout expires. If the request is done in the asynchronous mode then the server returns immediately providing an assigned request ID that can be used for polling via another API to check if the response from the endpoint is available. The request mode can be specified with query parameters "iot.sync" or "iot.async". By default if none of the parameters is set then the request is asynchronous. These parameters must not be set both. The asynchronous mode is a preferable way of doing invocation as it does not consume as much server resources as compared with the synchronous mode. Optionally, a timeout value in milliseconds may be provided with the "iot.timeout" query parameter.

The POST method must be supported by the endpoint resource to expect the request is forwarded to the endpoint. If not, the server rejects the request and replies with an error.

Request

Path Parameters
Back to Top

Response

Supported Media Types

200 Response

Successfully processed.
Body ()
Root Schema : ResourceRequestStatusImpl_receive
Type: object
Show Source

400 Response

Bad Request. The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

401 Response

Unauthorized. The request requires user authentication.

403 Response

Forbidden. The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated.

404 Response

Not Found. The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.

405 Response

Method Not Allowed. The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.

406 Response

Request Not Acceptable. The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

415 Response

Unsupported Media Type. The request entity has a media type which the server or resource does not support.
Back to Top

Examples

curl -X POST 
   -u <username>:<password>
   http://iotserver/iot/api/v2/apps/{app-id}/devices/{device-id}/resources/{subResources}

Example of Response Body

The following example shows the content of the response body in JSON format


{
"requestTime":"2016-07-22T10:44:57.746Z",
"responseEventTime":"2016-07-22T10:44:57.746Z",
"responseStatusCode":"HTTP 200: OK",
"method":"Request method",
"responseTime":"Time when the response is received by server",
"response":"Original response message payload JSON document",
"endpointId":"9463a4d5a5e-5364",
"links":[
{
"rel":"self",
"href":"http://iotserver/iot/api/version/resource/path"
},
{
"rel":"canonical",
"href":"http://iotserver/iot/api/version/resource/path"
}
],
"id":"edb62e256e9-7ed",
"complete":false,
"url":"http://iotserver/iot/api/version/resource/path",
"status":"RECEIVED"
}



Complete cURL Example

The following example shows compete cURL comand that can be used to perform described operation

curl -X POST 
   -u <username>:<password>
   http://iotserver/iot/api/v2/apps/6d1b39701a0d-4cf5/devices/6d1b39701a0d-4cf5/resources/{subResources}



Note that in the request, http://iotserver will be replaced by the name and port of your assigned IoT Cloud Service instance. The format of the Cloud Service instance is https:// myinstance-myidentitydomain.iot.us.oraclecloud.com and the default port is 443.
Back to Top