Turns to Service Callout if default target endpoint fails

pxzxz1
Participant IV

Hello Apigeeks

How to use Service Callout policy if target endpoint fails?

0 1 224
1 REPLY 1

Hi

I understand that you want to handle the case in which the designated target returns a non-success code. Maybe a status of 400 or 500, or maybe there is another way your proxy will determine that the call to the target was not successful. In the case of a not successful call to the target, you would like to call another target. You are asking if you can use ServiceCallout to accomplish this.

Yes, you can do that. But before you implement this, read this answer, which describes how to do what you want using TargetServers with retry.

By combining the TargetServer, isFallback, with retry, Apigee may do exactly what you want. Apigee can perform health monitoring of your endpoint if you use the TargetServer mechanism. It may satisfy your requirement.

If you still want to use ServiceCallout to do this work, you can do it, either:

  • within the scope of a faultrule, or
  • (better) by setting the SuccessCodes on the target, and using a conditional flow in the Response Flow of the target, to invoke your 2nd endpoint as desired.

Before doing any of this, I suggest you read and consider this.