Flask POST 400 Error on accessing request JSONObject
The best way to say if the correct content type for JSON is been set in Flask is the is_json function.Even if you do not want to use this method for some reason, you should make the if statement like the following
if "application/json" in request.headers["Content-Type"]:
The issue here, is that most of the clients out there do not just put application/json in Content-Type, but also the encoding, so the header results like this:
Content-Type: application/json; charset=utf-8
Hope this clears things now :)