In Odoo 11,
I have written a Web Controller to accept JSON data, as follows
class XController(http.Controller): @http.route('/test', type='json', auth='public', methods=['POST']
, csrf=False) def test(self, **post): _logger.info('CONNECTION SUCCESSFUL!!') _logger.info(post) name = post.get('name', False) if not name: Response.status = '400 Bad Request' return '{"response": "OK"}'
Now when I post the data using the following Request, I get JSON Post data correctly without any issues.
headers = {'Content-Type': 'application/json'}
data = {
"params" : { 'name': 'Kathy'} }
data_json = json.dumps(data) r = requests.post(url=url, data=data_json, headers=headers)
However since this request is made from an external system, the format of data is sent as follows,
data = {'name': 'Katty'}
ie without params inside data/content, Due to which, my post data is empty, how do I handle this.
Any help appreciated.
Odoo Controllers
1- https://learnopenerp.blogspot.com/2018/06/odoo-get-web-form-template-value-in-controller.html
2- https://learnopenerp.blogspot.com/2018/08/odoo-web-controller.html