Parse Integration Gateway Request
Fort this example, let’s parse a request sent to the Integration Gateway
Figure 1. The screenshot outlines the workflow that can be used to process the request.
The source code for the workflow example.
Integration gateway configuration
Endpoint |
|
Pre-filter |
Header: |
Processing |
Workflow processer: |
Post-filter |
|
cURL request
Below is an example of the cURL request that invokes the integration gateway and workflow:
curl -X POST "$CORTEZA_BASE/api/gateway/examples/payload" \
-H "Content-Type: application/json" \
-H 'Token: SOME_SECRET_TOKEN' \
-d '{"name":"Peter","id":123}';
JSEnv parsing function
Below is the extracted source code which should be used in the JSEnv function step:
var inputData;
try {
inputData = JSON.parse(input)
} catch (e) {
throw new Error('could not parse input payload: ' + e);
}
if (!inputData.name) {
throw new Error('could not parse input payload, name missing');
}
return {
id: inputData.id,
name: inputData.name
}