Webhook Response
There are cases where you need to modify the response of a webhook. Usually this is for some kind of validation that the webhook is setup correctly and can handle the response.
OttoFMS will use the value in the Exit Script step to set the response to the webhook. The response will be in JSON format.
The following is an example of a webhook response:
{
"useScriptResult": true,
"status": 200,
"statusMessage": "OK",
"headers": { "Content-Type": "application/json" },
"body": "{}"
}The useScriptResult property should be set to true. This will signal OttoFMS to use the properties in that JSON to set the response to the webhook.
In the response above the status is set to 200, the status message is set to "OK", the content type is set to "application/json" and the body is set to an empty JSON object.
Examples
Returning a simple text Result
Returning a 200 response with a simple text body and the text/plain content type.
{
"useScriptResult": true,
"status": 200,
"statusMessage": "OK",
"headers": { "Content-Type": "text/plain" },
"body": "Thank you for your submission!"
}Redirecting to a different page
If you're using a webhook as a form submission handler, you may want to redirect the user to a pretty HTML page that shows them some results or thanks them for their submission. You can host this page however you like (even just in the FMS HTTP folder) and then send a 303 response to redirect the user to the page.
{
"useScriptResult": true,
"status": 303,
"statusMessage": "OK",
"headers": { "Location": "https://myserver.com/thank-you.html" }
}