Getting "AttributeError: 'Request' object has no attribute 'json'" error

Viewed 19

Every time I try to send a post request to my server it's giving me "AttributeError: 'Request' object has no attribute 'json'". I am trying to get this working but it just wont.

This is the code for my server

from flask import Flask, request, abort


app = Flask(__name__)

@app.route('/webhook', methods=['POST'])
def webhook():
    if request.method == 'POST':
        print(request.json)
        return 'success', 200
    else:
        abort(400)

if __name__ == '__main__':
    app.run()`
 

I found this code on youtube but I've also tried other code but nothing worked everything gave the same error.

If anyone could help me it would be appreciated.

0 Answers
Related