Response Handler Configuration

Both Generic OAuth2.0 and Callout Authenticator API policies contain a Response Handler field in which you can configure an expression to determine how the response is being interpreted. You can use anything in the response received from the callout to your URL.

Inside of this Response Handler field, you have two expression objects available:

  • The "response" object which contains the response from the callout to your URL.
  • The "Result" object, which contains functions to control how you want the response to be handled.

You can modify the Response Handler expression according to your own response handling logic, using the functions inside the Result object defined in the following table:

Result FunctionsDescription

{
    ok: entity => { variant: 'OK', value: entity }


        continue: entity => { variant: 'CONTINUE', value:    entity }

    ignore: () => { variant: 'IGNORE' },

   
     err: reason => { variant: 'ERROR', reason: reason }

}

You call the OK function when you want the response to be accepted.
You call the Continue function to perform multiple callouts on a single request in sequence using the response of the first call out in a subsequent callout for further validation.
You call the Ignore function when you want the response to be ignored.
You call Error function when you want the response to result in an error.

The Continue function does not accept the request  (differentiating it from the OK function); rather, it just saves the value in the target path for further callouts.

Default Response Handler expression:

match response

{
       { statusCode: 200..<300, entity } => Result.ok(entity),
       { statusCode: 401|404 } => Result.ignore(),
       { status } => Result.err(status),
       _ => Result.err('Invalid response: ' + response.toString())

}