Service Callout Policy Fault Handling

Not applicable

When I following the GIT hub example that handing the authenticate failed of the service call out.

But install of go the raise fault step after authenticate failed. the platform will raise a system error.

ResponsCode :403 tread as a system error.

<Step>

<Name>ServiceCallOut-AuthenticateUser</Name> </Step>

<Step>

<Condition>authenticate.response.status.code != 200</Condition>

<Name>RF-AutenticateFailed</Name> </Step>

How to run in the raise fault step, when user credential failed and give a user friendly warning message.

0 3 4,188
3 REPLIES 3

Not applicable

we can set success codes Propertie , then when the response code 403 ,system can go to next step that we can raise a Fault Policy manually.

<Properties> <Property name="success.codes">XX,4XX</Property> </Properties>

Not applicable

Hi,

It always returns the 500 status code in case of any fault. First fetch the errordode from fault then assign it to a flow variable. You can define its own fault rule and set the response body or in default rule set the response body based on errorcode value.

For example steps.servicecallout.ErrorResponseCode.

For more details read following link:

https://community.apigee.com/questions/36968/service-callout-policy-fault-handling.html

Not applicable

@seamaslee: you can do two ways to give user friendly warning message.

1. Using a fault rule(without raise fault step): create a assign message policy for user friendly warning message and use that policy in fault rule

e.g:

<AssignMessage async="false" continueOnError="false" enabled="true" name="am_UnAuthorizedUser"> <DisplayName>am_UnAuthorizedUser</DisplayName> <Properties/> <Set> <Payload contentType="application/json">{calloutResponse.content}</Payload> <StatusCode>401</StatusCode> <ReasonPhrase>Unauthorized</ReasonPhrase> </Set> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="response"/> </AssignMessage>

<FaultRules> <FaultRule name="UnAuthorizedUser"> <Step> <Name>am_UnAuthorizedUser</Name> </Step> <Condition>(calloutResponse.status.code == 403 || calloutResponse.status.code == 403)</Condition> </FaultRule> </FaultRules>

<ServiceCallout async="false" continueOnError="false" enabled="true" name="sc_Users_Authenticate"> <Response>calloutResponse</Response> </ServiceCallout>

2. with raise fault step: Just change your ServiceCallout policy as continueOnError="true", then next step raise fault will be executed.