docs: clarify 415 vs 400 errors for Request.json

Clarify that Request.json raises different error codes:
- 415 Unsupported Media Type: when Content-Type is not application/json
- 400 Bad Request: when body is not valid JSON

This makes the documentation consistent with the API reference
and helps developers understand when each error will occur.

Fixes #5825

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Solari Systems 2026-01-20 00:46:26 -05:00
parent 2579ce9f18
commit 9bcad882e6
No known key found for this signature in database
GPG key ID: D78AAA416A915595

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