0

enter image description here

I have confusion that, Im using 202 status code, when I receive a POST request from a client (A) and B is processing it , passing the output to another endpoint(C). In this case I use 202 status code when B receives the request from A.( I have added the sample message flow.) B is not sending any other response back to A. So is that right using 202 or it should be 200 ?

My understanding is, we use 200 for GET calls, and for POST we use 202 if processing is pending. Here i have pending the processing and i forward that output to C. Not to A. So here is my confusion to use 202 or 200 is right?

Edit

If it is a call back endpoint, (eg: in this picture B), would it be appropriate to have 200? enter image description here

Ratha
  • 9,434
  • 17
  • 85
  • 163

1 Answers1

2

The main purpose of using 202 instead of 200 is for a server to communicate to a client: "From what I can tell, the request looks good. However, we haven't fully dealt with your request yet and we aren't 100% certain it's going to succeed".

So if someone does a request, the server immediately responds and then forwards the request elsewhere, a 202 makes sense to me. If the request fails at the C endpoint, A it will be too late for A to find out about this.

If you respond with 200, it tells a client that the request fully succeeded.

Evert
  • 93,428
  • 18
  • 118
  • 189
  • Thank you..So I assume having 202 is appropriate in this case because, any errors occurs at 'C' will be handled by diffreent channels( emails etc...) But having 200 is, I assume will give totally wrong aspect..For a GET call 200OK with response would be appropriate, but for a POST like this case, 202 is appropriate. Correct me if I'm wrong? – Ratha Dec 02 '21 at 00:50
  • If it is a call back endpoint, (eg: in this picture B), would it be appropriate to have 200? – Ratha Dec 02 '21 at 01:39