Logo
DevUtilsAll-in-one toolkit
Back to all codes
4224xx
4xx — Client Error

Unprocessable Content

The request was well-formed but was unable to be followed due to semantic errors.

What it means

The HTTP 422 Unprocessable Content (formerly Unprocessable Entity) response status code indicates that the server understands the content type of the request entity, and the syntax of the request entity is correct, but it was unable to process the contained instructions.

This is the most common status code used for REST API validation errors.

How it works

  • 1The client sends a POST request with valid JSON.
  • 2The server parses the JSON successfully (so it's not a 400).
  • 3The server's business logic sees that the 'age' field is -5, which is impossible.
  • 4The server returns 422 with a list of validation errors.

Why you're seeing this

  • Data validation failed (e.g., email not formatted correctly).
  • Business rules violated.

How to fix it

  • Read the error payload returned by the server and correct the submitted data.

Framework Implementations

Laravel (PHP)

// Laravel automatically returns a 422 if standard form validation fails.
$request->validate([
    'title' => 'required|unique:posts|max:255',
]);

Real-Life Scenarios

Use this extensively for form validation errors, invalid business logic states, and bad inputs in REST APIs.

Form Validation

A user submits a signup form but provides a password that is too short. The server returns 422 with the message 'Password must be at least 8 characters'.

HTTP Transaction

1. Client Request

POST /api/users HTTP/1.1
Content-Type: application/json

{"age": -5}

2. Server Response

HTTP/1.1 422 Unprocessable Content
Content-Type: application/json

{
  "errors": { "age": "Age must be a positive integer." }
}

SEO Implications

None.

Related Codes