Skip to content

422 Unprocessable Content — Meaning, Common Causes & How to Fix

422 4xx Client Error RFC 9110 §15.5.21

422 Unprocessable Content means: The request was well-formed (correct syntax and Content-Type) but semantically invalid: the server understands the payload yet cannot process the instructions. Popularized by WebDAV and adopted by Rails/Laravel/FastAPI-style validation layers. Client-error 4xx codes mean the request itself is the problem: malformed syntax, missing credentials, forbidden access, a nonexistent resource or a violated precondition. The server is telling the client what to change; retrying the identical request without a fix will reproduce the same error. In practice you will meet 422 when field-level validation failures: invalid email format, out-of-range values; business-rule violations that are not state conflicts (start date after end date); a json body that parses fine but fails the schema (wrong types, unknown fields). On the client side, read the per-field error details, correct the values, and resubmit; 422 will persist until the semantics are fixed, not the syntax. On the server side, return structured field errors (path, message, rejected value) with 422; keep 400 for malformed syntax so clients can distinguish the two failure classes.

Advertisement
Ad slot · ref-top

When 422 happens

  • Field-level validation failures: invalid email format, out-of-range values
  • Business-rule violations that are not state conflicts (start date after end date)
  • A JSON body that parses fine but fails the schema (wrong types, unknown fields)

How to fix it

On the client

Read the per-field error details, correct the values, and resubmit; 422 will persist until the semantics are fixed, not the syntax.

On the server

Return structured field errors (path, message, rejected value) with 422; keep 400 for malformed syntax so clients can distinguish the two failure classes.

Should you retry?

Not retryable as-is: change the request (credentials, payload, URL) first.

Debugging steps

When 422 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Read the error body first — well-designed APIs name the offending field or missing credential. Then diff your actual request, headers included, against the documented contract. For this code specifically, check whether the most common trigger applies to your situation: field-level validation failures: invalid email format, out-of-range values. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.

Notes & gotchas

422 separates 'parsed but semantically invalid' from 400's 'cannot parse', giving clients field-level remediation; frameworks like FastAPI, Laravel and Rails popularized this convention.

Examples

Raw HTTP
HTTP/1.1 422 Unprocessable Content
Content-Type: application/json
Content-Length: 129

{
  "error": "unprocessable_content",
  "message": "Field-level validation failures: invalid email format, out-of-range values"
}
curl
curl -i https://api.example.com/v1/resource   # observe the 422 response and its headers
JavaScript (fetch)
const res = await fetch("https://api.example.com/v1/resource");
if (res.status === 422) {
  const problem = await res.json(); // read field-level details
  // fix the request (credentials, payload, URL) — identical retries keep failing
  throw new RequestError(problem);
}
Python (requests)
import requests

res = requests.get("https://api.example.com/v1/resource", timeout=10)
if res.status_code == 422:
    problem = res.json()  # field-level error details
    # correct the request before retrying — identical retries keep failing
    raise RequestProblem(problem)

Frequently asked questions

Why do FastAPI and Laravel return 422?

Their validation layers distinguish 'parsed but invalid' (422) from 'cannot parse' (400). It gives clients precise, field-level remediation information.

422 vs 409: where is the line?

422: the payload itself is semantically wrong. 409: the payload is fine but conflicts with current server state (duplicates, version clashes).

Are 4xx errors always the client's fault?

By contract yes — the server asserts the request must change. In practice servers sometimes misuse 4xx for their own problems (e.g. 400 for internal validation bugs), so read the error body before blaming your client code.

Should I retry 4xx responses automatically?

Generally no: the server says the request must change. Exceptions are 408 (fresh connection), 425 (after handshake) and 429 (after Retry-After). Blind retries of 400/401/403/404 just burn quota.

Advertisement
Ad slot · ref-in-article

Try the JSON Validator

Check JSON syntax and locate errors by line and column.

Open tool →