Webhook validation Python Error: "POST / HTTP/1.1" 404 -

Hi, I can’t set up a webhook.
I use code from here:

from flask import Flask, request, abort, jsonify

app = Flask(__name__)


@app.route('/webhook', methods=['POST'])
def webhook():
    if request.method == 'POST':
        data = request.get_json()
        challenge = data['challenge']

        return jsonify({'challenge': challenge})

        # print(request.json)
        # return 'success', 200
    else:
        abort(400)


if __name__ == '__main__':
    app.run(debug=True)

But it didnt work.
For url generation i use ngrok.
I see challenges in ngrok:

{
    "challenge": "UEkR7-4VSXqp34ve39ghi8qLJew1qsjEI69Y2TLfvuq6SDAEJ-z88gZHHW3yPBHSV9HfwGOeLlAOwlp7qzAIUQ"
}

But ngrok terminal:
POST / 404 NOT FOUND

And python terminal:

 * Serving Flask app 'app'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: ****
127.0.0.1 - - [04/Dec/2023 14:48:13] "POST / HTTP/1.1" 404 -

What am I doing wrong?

Hello there @SVK,

I do not have experience with Python but is the endpoint being called? Do you have the URL set as https://www.yourngrokendpoint.com/webhook and whenever the trigger gets triggered, does your @app.route(‘/webhook’, methods=[‘POST’]) endpoint get called?

If so, please send us an email to appsupport@monday.com with as much information as possible and we will take a look with you :grin:

Cheers,
Matias

1 Like