Fault handling with multiple service callouts

Not applicable

Hi,

I have a flow with multiple service callouts. Currently I have a generic fault handling (see code below).

1. How can I modify it to handle faults and provide helpful error messages to the calling application? (For my current case, the error message returned from the individual service callouts is what I want to return to my end user.)

2. I would also like to send the appropriate HTTP error code. In my current code, no matter what the HTTP error code from the service callout comes back to me, Apigee is throwing HTTP 500. Instead, I would like to send a 404 if one of my service callouts errors with a 404.

My code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
    <Description/>
    <FaultRules>
        <FaultRule name="sc_failed">
            <Step>
                <Name>AssignMsg_sc_Failed</Name>
            </Step>
            <Condition>(fault.name = "ExecutionFailed")</Condition>
        </FaultRule>
    </FaultRules>
    <PreFlow name="PreFlow"><Request/><Response/></PreFlow>
    <PostFlow name="PostFlow"><Request/><Response/></PostFlow>
    <Flows>
        <Flow name="post /users">
            <Description>Create a user</Description>
            <Request>
                <Step>
                    <Name>ServiceCallout_1</Name>
                </Step>
                <Step>
                    <Name>ServiceCallout_2</Name>
                </Step>
            </Request>
            <Response>
                <Step>
                    <Name>ServiceCallout_3</Name>
                </Step>
            </Response>
            <Condition>(proxy.pathsuffix MatchesPath "/users")</Condition>
        </Flow>
    </Flows>
    <HTTPProxyConnection>
        <BasePath>/v1/...</BasePath>
		....
    </HTTPProxyConnection>
    <RouteRule name="default">
        <TargetEndpoint>default</TargetEndpoint>
    </RouteRule>
</ProxyEndpoint>

Please help.

1 1 1,154
1 REPLY 1

Not applicable

Hey @Ritwik Chatterjee,

Please go through the link attached, it contains all the answers to your queries.

https://github.com/apigee/api-platform-samples/tree/master/learn-edge/service-callout-2

Reply in case of further queries.