Getting your lesson ready…

0
Reading your lesson…
0:00 / 0:00

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