HTTP response status code 202 Accepted is returned by the server to indicate that a HTTP request has been received, although the processing is not yet complete and ultimately, the HTTP request may not be fulfilled.
When the 202 Accepted status code is sent, it can be taken only as an acknowledgment that the server has received the HTTP request and at this point, intends to process it. In practice, this may indicate that the server has validated the format of the request and has placed it into an internal queue for processing. For example, it may be a very long-running process, or part of a batch operation that is run daily.
There is no way for the server to return a HTTP response to indicate the eventual outcome of the HTTP request, so it is the client’s responsibility to check periodically, provided the server supports it.
Once the 200 OK status code of success has been received, the client can stop polling. Other examples of valid HTTP response status codes are 201 Created and 204 No Content. If 201 Created was returned to indicate that a new resource was created and is now available, it is specified by the Location response header field and available for the client to access. Status code 204 No Content may simply indicate that the job is complete but there is nothing for the client to retrieve as a result.
In the example, the client posts XML data to the server that defines a job to be complete. The server responds by acknowledging that the data was accepted. Subsequent HTTP requests by the client are used to determine whether the work is completed. Ultimately, the server indicates that the job is complete.
POST /job HTTP/1.1
Response to the initial request
HTTP/1.1 202 Accepted
Link: </job/status/125> rel="http://example.re/job-status"
Status request 1
Response to status request 1
HTTP/1.1 202 Accepted
Status request 2
Response to status request 2
HTTP/1.1 200 OK
After the 200 OK status code is received, the client stops polling and will act accordingly.
Apache HttpComponents Core
HTTP response status code 202 Accepted indicates that a HTTP request has been received and the processing is either not started or not yet complete. It does not indicate success or failure of the HTTP request.