Response flow in case of non-success response code, is not going in pre-defined manner

Not applicable

I have a proxy in which, if the response from the backend is 200, then everything works as expected. I have some policies attached to the response flows.

If I get a non success response code from backend(404), then it is not going through those flows and showing the response coming from backend. I need to customize the response in all cases. Can someone tell me how?

Solved Solved
0 8 5,614
1 ACCEPTED SOLUTION

Dear @Arun Kumar Reddy ,

The behavior is as designed. When the response code received from the backend is not a success (2xx, 3xx), the flow within Apigee will go into error flow. By default, Apigee Edge treats HTTP code 4XX or 5XX as errors, and it treats HTTP code 1XX, 2XX, 3XX as success. Find more information here.

You can use the success.codes property to configure the TargetEndpoint to treat HTTP response codes 400 and 500 as a success, along with the default HTTP codes. By treating those codes as a success, the TargetEndpoint takes over the processing of the response message, instead of invoking the Error flow.

<TargetEndpoint name="default">
  <HTTPTargetConnection>
    <Properties>
	  <Property name="success.codes">1xx,2xx,3xx,400,500</Property>
    </Properties>
    <URL>http://weather.yahooapis.com</URL>
  </HTTPTargetConnection>
</TargetEndpoint>

View solution in original post

8 REPLIES 8

Dear @Arun Kumar Reddy ,

The behavior is as designed. When the response code received from the backend is not a success (2xx, 3xx), the flow within Apigee will go into error flow. By default, Apigee Edge treats HTTP code 4XX or 5XX as errors, and it treats HTTP code 1XX, 2XX, 3XX as success. Find more information here.

You can use the success.codes property to configure the TargetEndpoint to treat HTTP response codes 400 and 500 as a success, along with the default HTTP codes. By treating those codes as a success, the TargetEndpoint takes over the processing of the response message, instead of invoking the Error flow.

<TargetEndpoint name="default">
  <HTTPTargetConnection>
    <Properties>
	  <Property name="success.codes">1xx,2xx,3xx,400,500</Property>
    </Properties>
    <URL>http://weather.yahooapis.com</URL>
  </HTTPTargetConnection>
</TargetEndpoint>

@Anil Sagar

Hi i have the similar issue when my target URL is wrong Apigee giving my 503 http response now it need to put a fault policy at response on proxy end because it's not hitting any target in this case.

do we have any solution for proxy end like you mentioned above in target end as adding properties.

@Vinay Soni , What do mean proxy end ? You mean to say proxy returning 503 using policy like AssignMessage ? Can i have an example of your issue ? I am not sure when you mean "Apigee giving 503" because, most of the cases apigee is just proxy no matter what is your target URL it just hits and comes back.

Attaching screenshot of my trace.

Sorry that's my bad. it's going to my target but if the target url hit the wrong hostname then i am getting 503 as expected but then i am not able to apply any policy on response. i have set property filed as mentioned above but still it's not working.the same thing is working if the error is 404.

@Vinay Soni , did you add 503 to success.codes property ? It should work..

<TargetEndpoint name="default">

  <HTTPTargetConnection>

    <Properties>

	  <Property name="success.codes">1xx,2xx,3xx,503</Property>

    </Properties>

    <URL>http://weather.yahooapis.com</URL>

  </HTTPTargetConnection>

</TargetEndpoint>

yes, i tried with 503 and 5xx both. it didn't work but it' working for 4xx.

can you please check ?

@Anil Sagar any idea on this(5xx) ..I am facing the same issue

As suggested above, I tried using following setting:

<HTTPTargetConnection> <SSLInfo> <Ciphers/> <ClientAuthEnabled>false</ClientAuthEnabled> <Enabled>true</Enabled> <IgnoreValidationErrors>false</IgnoreValidationErrors> <Protocols/> </SSLInfo> <Properties> <Property name="success.codes">400</Property> </Properties> <LoadBalancer> <Server name="AccessAmazon"/> </LoadBalancer> <Path>{targetpath}</Path> </HTTPTargetConnection>

but it didn't worked because when I got 400 HTTP code from the provider, my outbound response to my consumer was still 400 and it didn't got converted to 200 as I was expecting. Any idea why ??