Difference between HttpStatus.OK and HttpStatus.ACCEPTED

I am going to implement REST api. I want to know what is the difference between HttpStatus.OK

and HttpStatus.ACCEPTED


return new ResponseEntity<User>(u, HttpStatus.OK));



return new ResponseEntity<User>(u, HttpStatus.ACCEPTED);



source to share

1 answer

As per the Spring documentation given at this link


200 Ok means the request was successful. The information returned with the response depends on the method used in the request


202 Accepted. means that the request has been accepted for processing, but processing has not yet been completed. The request may or may not be subsequently applied as it may be prohibited when processing actually takes place.

for more information on HTTP response code definitions please visit the link



All Articles