From 2772eb7e12c95e9615d169769bed632f163301ea Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 2 Jun 2025 11:02:21 +0700 Subject: test with http and try catch --- fixco_api/controllers/api_v1/partner.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'fixco_api') diff --git a/fixco_api/controllers/api_v1/partner.py b/fixco_api/controllers/api_v1/partner.py index 77cac47..26ca9bf 100755 --- a/fixco_api/controllers/api_v1/partner.py +++ b/fixco_api/controllers/api_v1/partner.py @@ -1,6 +1,7 @@ from .. import controller from odoo import http from odoo.http import request +import json class Partner(controller.Controller): @@ -24,4 +25,10 @@ class Partner(controller.Controller): @http.route(prefix + 'wati/notification', auth='none', type='http', csrf=False, methods=['POST', 'OPTIONS']) def notification(self, **kw): - return + try: + data = json.loads(request.httprequest.data or '{}') # fallback to empty dict + except json.JSONDecodeError: + data = {} # if invalid JSON, treat as empty + + # Do something with `data` + return request.make_response("OK", headers=[('Content-Type', 'application/json')]) -- cgit v1.2.3