Skip to content

Commit 30da640

Browse files
authored
clarify 415 vs 400 errors for request.json (#5827)
1 parent 25642fd commit 30da640

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/patterns/javascript.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ In general, prefer sending request data as form data, as would be used
136136
when submitting an HTML form. JSON can represent more complex data, but
137137
unless you need that it's better to stick with the simpler format. When
138138
sending JSON data, the ``Content-Type: application/json`` header must be
139-
sent as well, otherwise Flask will return a 400 error.
139+
sent as well, otherwise Flask will return a 415 Unsupported Media Type
140+
error.
140141

141142
.. code-block:: javascript
142143
@@ -244,8 +245,9 @@ Receiving JSON in Views
244245

245246
Use the :attr:`~flask.Request.json` property of the
246247
:data:`~flask.request` object to decode the request's body as JSON. If
247-
the body is not valid JSON, or the ``Content-Type`` header is not set to
248-
``application/json``, a 400 Bad Request error will be raised.
248+
the body is not valid JSON, a 400 Bad Request error will be raised. If
249+
the ``Content-Type`` header is not set to ``application/json``, a 415
250+
Unsupported Media Type error will be raised.
249251

250252
.. code-block:: python
251253

0 commit comments

Comments
 (0)