problem in displaying error message

Not applicable

I have been trying to display different error messages for different faults. For this I have used multiple Raise_Fault policies. When I try to trace the proxy, the raise fault policies are getting called correctly but the error message which I have added in the payload tag is not getting displayed, only the error code is reflected correctly. Moreover for every error I get the same error script just the error code is different.

Below is the script that comes every time any of the fault policy is executed and just the error code gets changed . error message is not displayed

""{"fault":{"faultstring":"Execution of ServiceCallout RequestAccessToken failed. Reason: ResponseCode 400 is treated as error","detail":{"errorcode":"steps.servicecallout.ExecutionFailed"}}}""

0 6 550
6 REPLIES 6

Hi @PremaChoudhary,

It seems that the error you are getting is not from Raise Fault Policy but from Service Callout . The service callout service is returning 400 error code and hence in apigee further processing is stopped. If possible please share more details or share the trace.

Not applicable

trace-snapshot.png

Initially I also felt the same but the error code gets changed every time and its correct according to the error code I have included in the raise fault policy.

I was expecting a raise fault error in my trace and it got executed . I had given the error code for it as 415 which I can see in the script but the error message is missing.

{"fault":{"faultstring":"Execution of ServiceCallout RequestAccessToken failed. Reason: ResponseCode 415 is treated as error","detail":{"errorcode":"steps.servicecallout.ExecutionFailed"}}}

Is this the complete trace? From trace I am unable to figure out why this is happening. Need to try out in order to understand the behaviour. Let me test and see if I can generate a similar error.

@PremaChoudhary - Can you please upload the trace file if is it possible. Or else paste the contents of the raise fault policy that got executed.

Not applicable

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<RaiseFault async="false" continueOnError="false" enabled="true" name="Server-returns-JSON-only">

<DisplayName>Server returns JSON only</DisplayName>

<Properties/> <FaultResponse>

<Set>

<Payload contentType="text/plain"> Server returns JSON only </Payload>

<StatusCode>415</StatusCode>

<ReasonPhrase>Unsupported Media Type</ReasonPhrase>

</Set>

</FaultResponse>

<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </RaiseFault>

Raise Fault policy looks fine. Just wondering why are you getting steps.servicecallout.ExecutionFailed error. In trace I am not able to see any such policy. Need to know the flow(sequence of execution of policies). If possible please share the details/proxy.