OLD Using connector shape response scripts
How it works
Response scripts are just like any other custom script, except they receive additional information from the request - see lines 11 to 14 in the example below:
Implementing a response script
To implement a response script, you should:
Step 1: Write & deploy your response script
Response scripts are written and deployed in the usual way, via the custom scripts option. However, two additional options can be used for scripts that you intend to apply via connector shapes: response_code and message.
These options are only valid when the script is applied to a connector step as a response script
.
Response code
The response_code
determines how the process flow behaves if a connection request fails. Supported response_code values are:
0
Continue
1
Fail the connector step and retry. The connector step is marked as failed and the queue will attempt it again.
2
Fail the process flow and queue it to retry. The process flow is marked as failed and queued for a retry.
3
Fail the process flow and do not retry.
4
Force the connector to re-authenticate and retry the request.
Message
The message
is optional. If supplied, it is output in the run logs.
Example
Step 2: Apply the response script
To apply your response script, access settings for the required connector shape and select your script from the response script dropdown field.
Examples
Scenario 1
Here we handle the scenario where a connection response appears OK because the status
code received is 200
, but in fact the response body
includes a string (Invalid session
) which contradicts this. So, when this string is found in the response body, we want to retry the process flow.
In this case we return a response_code
of 2
with an message
of Invalid session
:
Scenario 2
Here we show how the payload
received from a connection request is checked for an order number and an order status - retrying the the process flow if a particular order status is found:
Related pages
Last updated