com.apama.cumulocity
Event GenericRequest


Generic requests can be sent to Cumulocity to allow any request in the Cumulocity REST API, using a REST URL and query string parameters.

Send this event to the GenericRequest.SEND_CHANNEL, and Cumulocity will respond on GenericResponse.SUBSCRIBE_CHANNEL channel with zero or more GenericResponse events and then one GenericResponseComplete.

The GenericResponseComplete will indicate if an error occurred during this request. If there was no error and the response returned a JSON payload then GenericResponse events will be sent. If it returned a non-JSON payload, then no GenericResponse events will be sent, but the GenericResponseComplete will contain the payload. If an error occurred then GenericResponseComplete will contain the error details or payload. In addition, if an error occurred then exactly one Error event will also be sent to the main context.

It is very important to report any error (error=true) from the GenericResponseComplete event, for example by logging the response at ERROR (or WARN) level. If failed responses are not logged it may be very difficult to debug problems caused by unexpected errors.
Since:
10.5.0.0
See Also:
com.apama.cumulocity.GenericResponseComplete
com.apama.cumulocity.GenericResponse

Constant summary
 stringCHANNEL := "CumulocityIoTGenericChain"

Channel to send these events to.
Deprecated:
[This channel constant has been deprecated. Use SEND_CHANNEL instead.]
 stringSEND_CHANNEL := "CumulocityIoTGenericChain"

Channel to send these events to.
 
Field summary
 integerreqId

Identifier for this request; must be generated using com.apama.cumulocity.Util.generateReqId().
 stringmethod

The HTTP verb. For example: RequestType.POST or RequestType.GET.
 stringpath

The HTTP path for the request.
 dictionary<stringstring>queryParams

Parameters to be passed in the HTTP query string. Depending on the type of request, some examples of what can be set: 'id', 'source', 'type', 'dateFrom', 'dateTo', 'pageSize', 'withParents', 'withTotalPages', 'currentPage', 'revert'.
 booleanisPaging

Whether this is a request whose results should be paged.
 anybody

The request body should be a dictionary or sequence which will be encoded as JSON. If no body is required for this request, an empty any can be provided.
 dictionary<stringstring>headers

Additional HTTP headers.
 
Constant detail

CHANNEL

string CHANNEL := "CumulocityIoTGenericChain"
Deprecated:
[This channel constant has been deprecated. Use SEND_CHANNEL instead.]
Channel to send these events to.

SEND_CHANNEL

string SEND_CHANNEL := "CumulocityIoTGenericChain"
Channel to send these events to.
Since:
10.5.2.0

Field detail

body

any body
The request body should be a dictionary or sequence which will be encoded as JSON. If no body is required for this request, an empty any can be provided.

headers

dictionary<stringstringheaders
Additional HTTP headers.

Example: To create a measurement collection using GenericRequest, the following headers are required
dictionary<string, string> requestHeaders := new dictionary<string, string>;
requestHeaders.add("accept","application/json");
requestHeaders.add("content-type", "application/vnd.com.nsn.cumulocity.measurementCollection+json");

isPaging

boolean isPaging
Whether this is a request whose results should be paged.

If true, then all pages of the result will automatically be retrieved. This can be changed by setting currentPage in the queryParams.

If pageSize is not specified in queryParams, a default pageSize will be added if paging is enabled.

method

string method
The HTTP verb. For example: RequestType.POST or RequestType.GET.

path

string path
The HTTP path for the request.

For example, "/measurement/measurements".

queryParams

dictionary<stringstringqueryParams
Parameters to be passed in the HTTP query string. Depending on the type of request, some examples of what can be set: 'id', 'source', 'type', 'dateFrom', 'dateTo', 'pageSize', 'withParents', 'withTotalPages', 'currentPage', 'revert'.


reqId

integer reqId
Identifier for this request; must be generated using com.apama.cumulocity.Util.generateReqId().