What Is a 202 Status Code?
The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place.
There is no facility in HTTP for re-sending a status code from an asynchronous operation.
The 202 response is intentionally noncommittal. Its purpose is to allow a server to accept a request for some other process (perhaps a batch-oriented process that is only run once per day) without requiring that the user agent’s connection to the server persist until the process is completed. The representation sent with this response ought to describe the request’s current status and point to (or embed) a status monitor that can provide the user with an estimate of when the request will be fulfilled.
- Source: RFC7231 Section 6.3.3
202 CODE REFERENCES
Rails HTTP Status Symbol :accepted
Go HTTP Status Constant http.StatusAccepted
Symfony HTTP Status Constant Response::HTTP_ACCEPTED
Python2 HTTP Status Constant httplib.ACCEPTED
Python3+ HTTP Status Constant http.client.ACCEPTED
Python3.5+ HTTP Status Constant http.HTTPStatus.ACCEPTED
When is a 202 status code used?
An HTTP 202 status code is used when a server receives the HTTP request and intends to process it.
This usually indicates that the server has validated the request’s format and has placed it in an internal queue for processing if it’s a long-running process or daily operation.
The client will need to periodically check the outcome of the HTTP response because the server has no way to return a status that would indicate the eventual outcome.
Once the 200 OK status is received, the client can stop checking on the response.
How to check a 202 status code
Because a server can’t return a status that would allow the client to see the eventual outcome of the request, the client will need to check the progress of the request.
A GET request to check on the status of the process or job.
202 status code example
If you want to see a 202 Accepted status code in action, we’ve got you covered. For this example, let’s say a client wants to data to a server to define a job that needs completed.
The server will respond that the request was received and acknowledged. The client will then need to send additional requests to determine whether the job has been completed. Eventually, the server will respond with a 200 OK status code when the job is finished.
Initial request
POST /job HTTP/1.1
Host: www.example.com
Content-Type: xml
Content-Length: 50
<?xml version=”2.0”>
<job>
<id>123</id>
<task>A101</task>
</job>
Initial response
HTTP/1.1 202 Accepted
Link: </job/status/123> rel=”http://www.example.com/job-status”
Content-Length: 0
Request #2
GET /job-status/123
Host: www.example.com
Response to request #2
HTTP/1.1 202 Accepted
Content-Length: 0
Request #3
GET /job-status/123
Host: www.example.com
Response to request #3
HTTP/1.1 200 OK
Content-Type: json
Content-Length: 25
{“success”:”true”}
Once the client receives the 200 OK status, the client can stop sending status requests and act accordingly.
Additional resources
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs
- W3Schools
Marketing Tips for Niche Industries
- Top/best Saas Marketing Agencies
- Tourism & Hospitality Statistics
- Urgent Care Marketing Ideas: 5 High-ROI Tactics
- WebFX: Your Education Digital Marketing Agency
- Why Auto Part Retailers Need Digital Marketing
- Why Digital Marketing is Essential for Auctioneers
- Your Guide to Digital Marketing for Exercise Equipment Companies
- Your Guide to Digital Marketing for Industrial Repair Companies
- Vision Care Industry Statistics
- 6 Best Heavy Equipment Marketing Agencies