Why does Flask answer 415 instead of 400?
A lesson on Flask pull request #5827. Computing, work level.
The docs used to call this a 400 error.
That was wrong.
Now they split the two cases.
In a Flask view, reading request.json with a missing or wrong Content-Type header raises 415 Unsupported Media Type.
So a 415 points at the header, not the JSON itself.
When you see 415, check that your fetch call sets Content-Type to application/json.
Questions in this lesson
- Your fetch call sends a request to a Flask view, and the server refuses it. The status code is not the usual 'bad request'. What do you think is the most likely cause?
- In your own words, what does a 415 from a Flask view tell you, and what would you check first in your fetch call?