In addition to the response parameter, each REST Adapter call also provides the complete adapter response as an output object. The adapter response contains the following:
Attribute | Type | Description | Allowed Values / Examples |
---|
httpStatus | Integer | HTTP status code of the adapter call. | 500 |
headers
| Array of HeaderField | |
|
body | Blob | HTTP body of HTTP response. Among others, the body contains - the response Object for successful calls
- an object of the RESTError class if the call has not been successful.
|
|
responseObject | Any | Response Object of the REST adapter call if the endpoint returns one (response output parameter). |
|
httpHeaderMap | Map of Entry | Header information as a map. The map contains arrays of header value strings whereas the header name is the key of the map.- Header names are lowercase and treated case insensitive.
- Multiple headers with the same name are treated as arrays.
Refer to HTTP Header Support for more information on the standard xUML HTTP headers. |
|
You can get the adapter response from the adapterResponse pin of the adapter.
Example
The following example shows how to get the REST error object in case of error and log it to the service log.
The adapter response is taken from the corresponding pin and transferred to a local object. The object does not necessarily need to be called adapterResponse - you can name it as you like.
Next, in case of error, the response is provided to an operation (logRESTError) that logs the error.
This operation takes the the adapter response from the response body and transforms it using action script (getResponseObjectFromBody). Parameter return is of type RESTError, a type that has been imported with the OpenAPI descriptor.
Using transcodeToString() and jsonToClass(), the body content is transformed to the error object.
set return = adapterResponse.body.transcodeToString("ISO-8859-1").jsonToClass();
This error object is provided as details parameter to the logger.
The error code to be logged is taken from the HTTP status code of the adapter response as described on Transforming Data on an Object Flow, using the following action script snippet:
adapterResponse.httpStatus.convertToString()