422

Unprocessable Content

Official
Due to a semantic error, the request could not be processed

General explanation of the 422 status code

The HTTP status code 422 Unprocessable Content is usually returned when the server received the client's request but could not process it due to a semantic error.

This essentially means that the client's request was not understood or accepted by the server because it may have been incomplete or incorrect. A common example of this is when the client attempts to send a form request to the server, but the form field was not filled in correctly.

The server will usually also send back a message in the body of the response giving more details about why the request is unprocessable. It is then up to the client to read and correct this information in order to make a successful request to the server.

Specification of the HTTP status code 422

The 422 Unprocessable Content status code means 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 (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions. For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.

Source / Quote by: The 422 Unprocessable Content HTTP Status Code is specified by section 11.2 of RFC4918.

How to throw a 422 statuscode with PHP?

To throw the HTTP status code 422 on a web page, the PHP function http_response_code can be used. The syntax is as follows: http_response_code(422) (PHP 5 >= 5.4.0, PHP 7, PHP 8)

Test the 422 HTTP status code

In order to be able to display the HTTP status code (in this case 422 Unprocessable Content) and other information on the client side, the development console must be opened with F12. Afterwards you have to navigate to the tab "Network". Now you can open the page, in the network tab you should see the web page (example index.php). This must be selected and then the Herder section must be selected. Here the user will see the following result:

Status code 422 Unprocessable Content
Overview
URL: https://http-statuscode.com/errorCodeExample.php?code=422
Status: 422 Unprocessable Content
Those: Network
IP address: XX.XX.XX.XX
Status code 422 Unprocessable Content

How do I solve the problem with the 422 status code?

The HTTP status code 422 Unprocessable Content can have several reasons. As already described in the general explanation, HTTP status code 422 Unprocessable Content is thrown when semantic errors are present

.

HTTP status code 422 Unprocessable Content is thrown in WordPress, how do I fix the error?

Either a recently installed plugin is faulty, even customised code is semantically incorrect, or it is a broken database.

HTTP 422 Unprocessable Content is thrown because of a broken database, this is the solution

.

To fix the database problem, WordPress plugins like "WP-DBManager" can be used. If access to WordPress itself is no longer possible, the database must be accessed directly. Hosters usually provide tools for this purpose. The best-known tool is PhpMyAdmin. After logging in, the database must be selected and then all tables must be selected via the checkbox. Then select "Rapair table" in the select box at the bottom. The action is executed by clicking on the "Go"

button.

Now the problem should no longer occur.

HTTP 422 Unprocessable Content is thrown because of an error in the code

.

If there is a semantic error in the code, the last change should be reverted, or the last installed WordPress plugin should be disabled or removed via FTP / SFTP.

Now the problem should no longer occur.

How to create a custom error page for the 422 status code

Creating your own 422 Unprocessable Content error page is relatively easy with the web server "Apache" as well as with the web server "NGINX".

Apache Webserver

The web server "Apache" is one of the most popular web servers on the Internet. To create an own 422 Unprocessable Content error page in "Apache", the following change must be made in the following file.

File: .htaccess
ErrorDocument 422 /errors/422.html

NGINX Webserver

Similar to the web server "Apache", "NGINX" is also widely used on the Internet. To create your own 422 Unprocessable Content error page in "NGINX", the following change must be made in the following file.

File: sites-enabled/default
error_page 422 /422.html;
location = /422.html {
    root /usr/share/nginx/html;
    internal;
}

Browser compatibility of the 422 status code

Chrome no data
Edge no data
Firefox no data
Opera no data
Safari no data
Chrome Android no data
Firefox for Android no data
Opera Android no data
Safari on iOS no data
Internet no data
WebView Android no data

Constants in programming languages

http.StatusUnprocessableEntity
Response::HTTP_UNPROCESSABLE_ENTITY
http.HTTPStatus.UNPROCESSABLE_ENTITY
:unprocessable_entity
Author: Tony Brüser
Author: Tony Brüser

Tony Brüser is an enthusiastic web developer with a penchant for HTTP status codes.

LinkedInGitHub