DEV Community

Cover image for What is a 422 - Unprocessable Entity/Content?
Sohail Pathan
Sohail Pathan

Posted on

What is a 422 - Unprocessable Entity/Content?

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

Possible/Most common causes:

  1. Semantic Error: The most frequent cause of a 422 error is when there is incorrect data logic or semantics, such as referring to an entity that does not exist. (e.g., a foreign key that points to a non-existent record).

  2. Missing Required Fields: When the type of one or more input fields does not match what the server expects (e.g., string instead of integer, or vice versa).

How to Fix a 422 - Unprocessable Entity/Content?

  1. Validate the input: Validate the input received by the server to ensure that it adheres to the defined structure and data types.

  2. Logging: Implementing a logging mechanism for diagnosing the details of the error including the type of request, the origin of the request, and the time of the request will help in fixing the error.

Image Credit: Sitechecker.com

Discover more developer articles and tutorial here

Top comments (0)