422 Unprocessable Content HTTP Status Code

Description

The HTTP status code 422 stands for "Unprocessable Entity". It is part of the WebDAV extension to the HTTP protocol, and it's used to indicate that the server understands the content type of the request entity (hence a 415 Unsupported Media Type status code is inappropriate), and the syntax of the request entity is correct, but it was unable to process the contained instructions. This status code is typically used when the server requires certain validation of the request data, and the provided data fails those validation rules.

For example, if a client submits a form with a field that requires a specific format or value range and the submitted value doesn't meet those requirements, the server might respond with a 422 status code indicating that the server understands what type of data the client is submitting, but can't process it due to semantic errors or validation failures.

Status

HTTP
422 Unprocessable Content

Common Causes

Here are the common causes for receiving a 422 status code:

  1. Validation Errors: The most common cause for a 422 error is validation errors in the data sent by the client. This could be due to data being in the wrong format, missing required fields, or containing invalid values.

  2. Semantic Errors: Even if the syntax of a request is correct (e.g., JSON format is valid), there can be semantic errors with the data. For example, a field that is expected to be a unique identifier already exists, or a reference to another resource does not exist.

  3. File Size Limit: When uploading files, if the file size exceeds the server's allowed limit, a 422 error might be returned, especially if the server uses this status code to indicate that the request entity is in a correct format but cannot be processed due to application-specific conditions.

  4. Data Type Issues: Even with correct data formats, the types of specific fields can cause issues, such as passing a string where an integer is expected.

  5. Business Logic Conditions: Servers might also return a 422 error when the request fails to meet certain business logic conditions required to process the request. For example, attempting to perform an operation that's not allowed given the current state of the target resource.

  6. Constraint Violations: This includes violations of database constraints, like unique constraints, foreign key constraints, or any other data integrity constraints that the application must enforce.

The response body of a 422 error typically contains further details about the errors encountered, which can guide the client in making a successful request.

Browser Support

The following table will show you the current browser support for the 422 Unprocessable Content HTTP status code.

Desktop
Edge Chrome Firefox Opera Safari
?????
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
??????

Last updated by CSSPortal on: 1st April 2024