Define a Separate Validation or Pre-flight Request Handling for a Trigger

Requests contain an identifier in the header or payload called as validation requests or pre-flight requests. They usually differ in structure from the actual request.

Some single producer applications send a validation request contracts during the registration of a webhook endpoint. The Rapid Adapter Builder developer must handle these validation requests differently as compared to the design of the default trigger behavior.

As a first step you must identify the validation request contract from the producer application. For this example, assume the following:

  • Validation request includes the header event-type with the value SubscriptionValidation.

  • The JSON payload includes the validation code.

  • Oracle Integration returns 200 OK response with the validation code.

  1. Define a pass-through trigger in the adapter definition document.
    For more information, see Define a Pass-through Trigger.
  2. In the triggers section of the adapter defintion document, add a validationRequests code snippet to the trigger code.
    Sample code:
    "validationRequests": [{
                "condition": "${.request.headers.\"event-type\"==\"SubscriptionValidation\"}",
                 "response": { 
                     "status": 200,
                    "body": {
                        "validationResponse": "${.request.body.validationCode}"
                    }
          }
    ],

    Sample code for a pass-through trigger with a validation request:

    "triggers":{
       "pageChangeEvent": {
          "displayName": "Wiki Page Updated Event",
          "description": "This trigger detects when a Wiki Page Updated Event is raised.",
          "type": "webhook",
          "httpMethod": "POST",
          "request": {
            "schemaType": "application/schema+json",
            "schema": {
              "$ref": "#/schemas/eventSchema"
            }
          },
         "validationRequests": [{
                "condition": "${.request.headers.\"event-type\"==\"SubscriptionValidation\"}",
                 "response": { 
                     "status": 200,
                    "body": {
                        "validationResponse": "${.request.body.validationCode}"
                    }
          }
         ]
        }
    }