Hello,
I’m trying to create a webhook with the python-asana client within Odoo 14.
I get the X-Hook-Secret but when I try to send it back to asana, I get this error:
"Invalid Request: The remote server which is intended to receive the webhook did not respond with the handshake secret.
from odoo import http
from odoo.http import request, Response
BASE_URL = '...'
WEBHOOK_ENDPOINT = 'receive-webhook/'
def register_webhook(resource_id = '...'):
req = {"resource": resource_id, "target": BASE_URL + WEBHOOK_ENDPOINT }
AsanaClient.webhooks.create_webhook(req)
class WebHookController(http.Controller):
@http.route('/'+WEBHOOK_ENDPOINT, type='json', auth='none', csrf=False)
def post(self, **kwargs):
# Retrieve the X-Hook-Secret header from the request
handshake_secret = request.httprequest.headers.get('X-Hook-Secret')
if handshake_secret:
# Send the handshake secret back to complete the handshake
headers = [('X-Hook-Secret', handshake_secret)]
return Response("ok", status=200, headers=headers)
else:
# process the request...
pass
Thank you for any suggestions!