I want to show my new module under "Coba Idea" module.
I want to experiment with webhook, here is my code for both the .py and .xml
.py :
class MyWebhook(models.Model):
_name = 'webhook.webhook'
_description = "Coba Webhook"
payload = fields.Text("Payload")
@http.route('/webhook', type='http', methods=['POST'], auth="none")
def webhook_listen(self, **kwargs):
result = {'success': _("Data get")}
try:
wh= self.env['webhook.webhook'].create({
'payload': kwargs.get('message')
})
result = {'success': _("Data Saved")}
except Exception as e:
logger.exception("Fail to save data %s", kwargs.get('message'))
result = {'error': str(e)}
return json.dumps(result)
Tried the webhook with curl,
curl -i -X POST -d "ok" http://localhost:8068/webhook
Thanks