Home > Blockchain >  HTTP Status code 202 vs 200 for a POST request
HTTP Status code 202 vs 200 for a POST request

Time:12-02

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

CodePudding user response:

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.

  • Related