Asynchronous call to different proxy base path upon 200 response

Hello Apigee ninjas,

I'm trying to make an asynchronous call to another proxy base path upon 200 response.

For an example, I have /{id}/payment -> 200 OK -> sends 200 response JSON payload to /{id}/payment-history

Is there a way to do this?

Thank you!

0 1 307
1 REPLY 1

Yes.

You can use a ServiceCallout with a LocalTargetConnection. Omit the response to make it asynchronous.

Something like this:

<ServiceCallout name="Service-Callout-1">
  <Request clearPayload="false" variable="myRequest"/>
  <!-- omit the response to make the call asynchronously -->
  <!--
    <Response>calloutResponse</Response>
  -->
    <Timeout>60000</Timeout>
    <LocalTargetConnection>
        <APIProxy/>
        <ProxyEndpoint/>
        <Path/>
    </LocalTargetConnection>
</ServiceCallout>

The doc for ServiceCallout says:

If this element (Response) is omitted, the API proxy does not wait for a response; API Proxy flow execution continues with any subsequent flow steps. Also, to state the obvious, with no Response element, the response from the target is not available for processing by subsequent steps, and there is no way for the proxy flow to detect a failure in the remote call. A common use for omitting the Response element when using ServiceCallout: to log messages to an external system.