Need to call an external api from service callout and based on the response raise fallout

I have a requirement where before calling the target endpoint of /abc....i need to call an external api for example /validate ....and based on the response from validate api...true or false...i want to take decision whether to raise fallout or go ahead with the /abc call further.

as of now i am considering service callout to call the /validate api which should have the complete different request body then actual /abc proxy call.

as of now, when i call the apigee proxy endpint with a body. same body gets appended in service callout as well. i do not want that. service callout should have different body all together.

can anyone please help what all policies should i use and if sample code is available.

0 1 188
1 REPLY 1

Not applicable

use below code

<ServiceCallout async="false" continueOnError="false" enabled="true" name="service-callout">
    <DisplayName>service-callout</DisplayName>
    <Properties/>
    <Request clearPayload="true" variable="myRequest">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    </Request>
    <Response>myResponse</Response>
    <HTTPTargetConnection>
        <URL>https://xyz.com</URL>
    </HTTPTargetConnection>
</ServiceCallout>

In Request clear payload will create new request names my request , this will not take the original request.

The service callout response will be stored in myResponse, so you can extract that. That will not go as payload to backend. The original request will continue to your backend.

The raise fault you can use after extracting service callout response.