Here is a snippet of my target-endpoint configuration,
<TargetEndpoint name="default">
<Description/>
<FaultRules>
<FaultRule name="convertErrorsToSuccess">
<Step>
<Name>AssignMessagesmoothOutErrors</Name>
</Step>
<Condition>response.status.code != 200</Condition>
</FaultRule>
</FaultRules>
....
As, you can see I have attached an AssignMessage Policy in the FaultRule to handle non 200 responses. Here it goes,
<AssignMessage async="false" continueOnError="false" enabled="true" name="AssignMessagesmoothOutErrors">
<DisplayName>AssignMessage.smoothOutErrors</DisplayName>
<Copy/>
<Set>
<Payload contentType="application/json">
\{"error": "There was some error at backend.", "originalStatusCode" : {message.status.code}}
</Payload>
<StatusCode>200</StatusCode>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="response"/>
</AssignMessage><br>
As part of payload, I want to send back the original status code received from backend. Above, configuration gives me ‘200’ as a status code.
I’m very new to Apigee. Please help me out.