diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2025-06-02 11:02:21 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2025-06-02 11:02:21 +0700 |
| commit | 2772eb7e12c95e9615d169769bed632f163301ea (patch) | |
| tree | c5a04cbab90bec68c2f10696f443ccfd27f8d66d /fixco_api | |
| parent | 5a8b9aa8fdc8c71fc9cb070e291dc5098da5ae7f (diff) | |
test with http and try catch
Diffstat (limited to 'fixco_api')
| -rwxr-xr-x | fixco_api/controllers/api_v1/partner.py | 9 |
1 files changed, 8 insertions, 1 deletions
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')]) |
