How can we ignore similar request for the backend service.

Not applicable

Hi,

Here is my problem statement.

Let's say i have an api hosted in apigee. The api returns 400 http status in case of input data is wrong and 500 in case of any system exception occurred while processing the request. When Client receive a 400 response from the api, he/she is supposed to change the request and send the request again to get a valid 200 response. But our clients doesn't have great system, they don't check the error very often. So even though they get 400/500 response from the api, the keep trying in with same input in every 30 sec or so. As a result we are getting lot of unwanted calls which doesn't do anything other than increase the heap. When you have large number of clients using a api, it is very difficult to guide each and everyone to implement retry logic properly. We want to avoid such unwanted calls. If apigee has some kind of mechanism to handle this then we won't have large number of unwanted requests at backend service.

Thank you in advance.

-Krishanu

Solved Solved
0 1 933
1 ACCEPTED SOLUTION

Not applicable

If you know certain conditions where the requests are valid, you can check this logic in the Apigee layer. If the request is malformed, you can raise a fault and stop the message flow, sending back a 400 Bad Request response before the request ever reaches the backend service.

Depending on the valid input parameters, you may need to check queryparams/headers. You can conditionally execute the RaiseFault policy to stop the message flow and send back a fault response:

http://apigee.com/docs/api-services/content/raise-...

The Java Regex operator can be powerful to conditionally execute the RaiseFault policy:

http://apigee.com/docs/api-services/api/conditions...

An example use of the regex to execute a RaiseFault policy when a id queryparam contains invalid format:

<Step>
    <Name>raiseFaultInvalidId</Name>
    <Condition>(!(request.queryparam.id ~~ "^\d{1,3}-\d{1,2}-\d{1,4}$"))</Condition>
</Step>

View solution in original post

1 REPLY 1

Not applicable

If you know certain conditions where the requests are valid, you can check this logic in the Apigee layer. If the request is malformed, you can raise a fault and stop the message flow, sending back a 400 Bad Request response before the request ever reaches the backend service.

Depending on the valid input parameters, you may need to check queryparams/headers. You can conditionally execute the RaiseFault policy to stop the message flow and send back a fault response:

http://apigee.com/docs/api-services/content/raise-...

The Java Regex operator can be powerful to conditionally execute the RaiseFault policy:

http://apigee.com/docs/api-services/api/conditions...

An example use of the regex to execute a RaiseFault policy when a id queryparam contains invalid format:

<Step>
    <Name>raiseFaultInvalidId</Name>
    <Condition>(!(request.queryparam.id ~~ "^\d{1,3}-\d{1,2}-\d{1,4}$"))</Condition>
</Step>