422 Unprocessable Content
The server understood the request and its format, but the data inside failed validation, like a missing field or bad email.
What 422 Unprocessable Content means
It started in WebDAV (RFC 4918) as 422 Unprocessable Entity and was brought into the main HTTP spec by RFC 9110 under the name Unprocessable Content.
Use 400 when the request is malformed, such as broken JSON. Use 422 when the JSON parses fine but the values are wrong. Rails, Laravel and FastAPI all return 422 for validation errors by default.
Common causes
- A required field is missing or empty.
- A value has the wrong type or format, such as text where a number is expected, or an invalid email.
- A value breaks a business rule, such as an end date before the start date.
How to fix 422 Unprocessable Content
- Read the error response. Validation APIs usually list each failing field and why.
- Check the request against the API's schema or documentation.
- As a visitor, look for form fields marked with errors and correct them.
Example response
HTTP/1.1 422 Unprocessable Content
Content-Type: text/plain; charset=utf-8
422 Unprocessable ContentHow to check for a 422 response
cURL
# Print only the status code
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/JavaScript (Node.js)
const res = await fetch("https://example.com/");
if (res.status === 422) {
console.log(res.status, res.statusText);
}Python
import requests
res = requests.get("https://example.com/")
if res.status_code == 422:
print(res.status_code, res.reason)Go
res, err := http.Get("https://example.com/")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 422 {
fmt.Println(res.Status)
}Specification
422 Unprocessable Content is defined in RFC 9110, section 15.5.21.
Related status codes
- 400
The server could not understand the request because something in it is malformed, like broken JSON, bad syntax or invalid headers.
- 409
The request conflicts with the current state of the resource, such as saving a version that someone else already changed.
- 415
The server refuses the request body because its format, given by Content-Type or Content-Encoding, is not supported.