HTTP Request Payload
The execution of Data Service logic is triggered automatically by an HTTP request incoming to the service endpoint. The contents of an HTTP request can be accessed using CTL functions. Request payload and request parameters are also accessible in component attributes.
Payload incoming in the request can be accessed in three ways. One is by direct reading of an input stream using request:body as an input file URL of a reader component. If the request contains HTTP multipart message (e.g. multiple attachments), you can access individual payloads using request:part:[part_name] in the reader file URL.
Payload can also be accessed using the CTL function getRequestBody. The function however returns whole payload as string, so it is not recommended to use it for large payloads that may not fit into the memory.
Note: Payload stream can only be accessed once when accessed via request:body or request:part:[part_name].
A second attempt to parse the stream will cause a failure.
By using the getRequestBody()
CTL function, you may access the payload repeatedly, as the function will store the payload.
The third option is to connect an edge to the "Body" output port of the REST Job Input component. The metadata of the edge will be automatically set depending on the selected Input Format:
-
Binary: Streams the request body in chunks. Connect an arbitrary reader component and set the URL to
port:$0.body:stream
. -
String: Returns the whole request body as a single string.
-
JSON: Parses the whole body as a JSON document into a
variant data field for processing with CTL functions. If the JSON payload doesn’t fit into memory, use
JSONExtract with request:body URL instead.
Compatibility
Since CloverDX 5.12.0, "JSON" is pre-selected as the request body format for newly created Data Service REST Jobs. REST Jobs created in previous versions are not affected and will keep using the "Binary" request body format.