How to extract Service Callout Response when Http Backend Response Error is 500 ?

Hi Everyone, 
I have a proxy A and I want to extract custom reponse collected from Backend B when response code is from Backend is 500. 
Here is the result i have corresponding to "Error Content Body": 
{
"fault": {
"faultstring": "Execution of ServiceCallout SC-XXXX failed. Reason: ResponseCode 500 is treated as error",
"detail": {
"errorcode": "steps.servicecallout.ExecutionFailed"}}} 
When i use Extract Variable the calloutResponse variable is empty in trace. 
 
I want access to "Service Callout Response Body" : <xml> custom reponse error from backend</xml>  where http error code from backend is 500.

Best Regards

Solved Solved
0 3 703
1 ACCEPTED SOLUTION

You can use the success.codes Property to specify that response code 500 should not be treated as an error.

 

<ServiceCallout name='SC-1'>
  <Request variable='outboundRequest'> ...  </Request>
  <Response>calloutResponse</Response>
  <HTTPTargetConnection>
    <SSLInfo> ... </SSLInfo>
    <Properties>
      <!-- look here -->
      <Property name='success.codes'>2xx, 4xx, 5xx</Property>
    </Properties>
    <URL>https://api.example.com/</URL>
  </HTTPTargetConnection>
</ServiceCallout>

 

Check the documentation for more information.

 

View solution in original post

3 REPLIES 3

You can use the success.codes Property to specify that response code 500 should not be treated as an error.

 

<ServiceCallout name='SC-1'>
  <Request variable='outboundRequest'> ...  </Request>
  <Response>calloutResponse</Response>
  <HTTPTargetConnection>
    <SSLInfo> ... </SSLInfo>
    <Properties>
      <!-- look here -->
      <Property name='success.codes'>2xx, 4xx, 5xx</Property>
    </Properties>
    <URL>https://api.example.com/</URL>
  </HTTPTargetConnection>
</ServiceCallout>

 

Check the documentation for more information.

 

Thank you for the quick answer. 

Best Regards.

I have similar situation reponse code from backend is coming 400 but service callout error code being set 500. 

I have to return backend error code 400 but not able to retrive it. Please help.

 

Here is the result i have corresponding to "Error Content Body": 
{
"fault": {
"faultstring": "Execution of ServiceCallout SC-XXXX failed. Reason: ResponseCode 400 is treated as error",
"detail": {
"errorcode": "steps.servicecallout.ExecutionFailed"}}}