How to handle different response on each api call in apigee.

Hi 

I have a unique requirement to implement an API that return different response status code and response every time it hits for specific number of times. Like

First API calls should return 200 with a null response.

When you hit it for the second time you will get 400 with an error body.

Third try you will get 403 with a response body.

Fourth try you will get 404 with a response body.

fifth try you will get 500 with a response body.

Sixth try 503 with the response body.

and after it should start again with 200 response and so on in a loop.

@DChiesa 

@dchiesa1 

Solved Solved
0 2 146
1 ACCEPTED SOLUTION

It doesn't sound like you're solving an API Management problem.  I don't know what kind of problem that is, actually.  The problem you described is artificial and contrived; it sounds like a homework assignment.  

It could be a fun problem to tackle, but unfortunately, Apigee won't help you. Apigee acts as a stateless proxy. It's not well suited to "counting calls" in the way you described. If I were trying to solve the problem you described, I'd build something in nodejs, or C#, or a Java/express app, ... something that can retain state. 

 

View solution in original post

2 REPLIES 2

Can u plz share what problem ur trying to resolve by this approach, it's not clear 

 

 

When u say 1st call 200 as status code and 2nd call as 400, here are you trying to make backend call or just simple mock these response on Apigee

It doesn't sound like you're solving an API Management problem.  I don't know what kind of problem that is, actually.  The problem you described is artificial and contrived; it sounds like a homework assignment.  

It could be a fun problem to tackle, but unfortunately, Apigee won't help you. Apigee acts as a stateless proxy. It's not well suited to "counting calls" in the way you described. If I were trying to solve the problem you described, I'd build something in nodejs, or C#, or a Java/express app, ... something that can retain state.