Failed to decode JSON object: (e)
Package:
flask
56479

Exception Class:
BadRequest
Raise code
):
from .debughelpers import attach_enctype_error_multidict
attach_enctype_error_multidict(self)
def on_json_loading_failed(self, e: Exception) -> "te.NoReturn":
if current_app and current_app.debug:
raise BadRequest(f"Failed to decode JSON object: {e}")
raise BadRequest()
class Response(ResponseBase):
"""The response object that is used by default in Flask. Works like the
response object from Werkzeug but is set to have an HTML mimetype by """
🙏 Scream for help to Ukraine
Today, 2nd July 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too!
We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Links to the raise (1)
https://github.com/pallets/flask/blob/83f7efa04708a22c9701488f0f29b59c2b756bef/src/flask/wrappers.py#L97See also in the other packages (1)
(❌️ No answer)
werkzeug/failed-to-decode-json-object-e/
Ways to fix
Summary: Need to send valid to the post endpoint
Code to run Flask API:
from flask import Flask, request
app = Flask(__name__)
@app.route('/post',methods = ['POST'])
def post():
if request.method == 'POST':
return request.get_json()
if __name__ == '__main__':
app.run(debug = True)
Code to reproduce (WRONG):
curl -X POST http://127.0.0.1:5000/post -H "Content-Type: application/json" -d '{"key", "value"}' # Invalid json
Working version (Fixed):
curl -X POST http://127.0.0.1:5000/post -H "Content-Type: application/json" -d '{"key": "value"}' # <--- FIX: change to valid json
Add a possible fix
Please authorize to post fix