Fix documentation for JSON error codes

Clarify that request.json raises:
- 400 Bad Request for invalid JSON content
- 415 Unsupported Media Type for wrong Content-Type header

Fixes #5825
This commit is contained in:
Tsotne Okrostsvaridze 2025-12-10 23:10:07 +01:00
parent 2579ce9f18
commit 30cfe75792

View file

@ -244,8 +244,9 @@ Receiving JSON in Views
Use the :attr:`~flask.Request.json` property of the
:data:`~flask.request` object to decode the request's body as JSON. If
the body is not valid JSON, or the ``Content-Type`` header is not set to
``application/json``, a 400 Bad Request error will be raised.
the body is not valid JSON, a 400 Bad Request error will be raised. If
the ``Content-Type`` header is not set to ``application/json``, a 415
Unsupported Media Type error will be raised.
.. code-block:: python