When upgrading from Flask 2.X to Flask 3.x I noticed that some POST requests started failing with 415: unsupported media.
This is because I was using request.get_json()
to determine if a post was json or not before branching to process either a form or a JSON object.
The solution was to swap to the request.is_json
property and then only run get_json()
if is_json
is true.
Reference
https://stackoverflow.com/questions/77812697/python-flask-server-error-415-unsupported-media-type-when-using-jsonify https://flask.palletsprojects.com/en/stable/api/#flask.Request.get_json