'Troubleshooting Zapier Webhook POSTING to Flask Server
I am trying to use my Flask server to receive webhooks in a POST from a Zap, but I'm getting a 500 Internal Server Error when I test.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
TypeError: receive_webhook() missing 1 required positional argument: 'request'
Here is my handler for the webhook:
@app.route("/webhook", methods=['POST'])
def receive_webhook(request):
print(request.json)
return request.json
Here's a screenshot of my Zap I am trying to send the POST from
Thanks for any assistance.
It seems like Zapier is calling my handler with no argument. Shouldn’t it be passing the payload as that request argument or am I misunderstanding something here?
Edit: Also, if it's relevant, I'm using Nginx and Gunicorn for hosting. On an Ubuntu Linode.
Solution 1:[1]
I figured out the problem. I was using the Flask request module incorrectly. This code made it work -
@app.route("/webhook", methods=['POST'])
def receive_webhook():
print(request.data)
return request.data
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alex Hermstad |
