Skip to Content
Menu
This question has been flagged

I'd like to accept and respond to JSON requests in Odoo from sources that may be out of my control. The reason this is not straightforward is because Odoo is forcing me to use JSON-RPC, which is not suitable for the source I'm interacting with.

For example, if I set the route type to "http" in the `@http.route` decorator, Odoo rejects the request if the mimetype is "application/json" but the body has no content. This isn't going to work in my case because I may not be able to choose what the other source sends to me. Additionally, I am unable to send back a custom JSON response unless the incoming request doesn't have the "application/json" mimetype, which again is not in my control.

I have done a lot of searching on the internet and read much of Odoo's HTTP source code. The "solution" I keep seeing everywhere is to monkey patch the `JsonRequest` class one way or another. This allows me to indeed respond with whatever I want, however it doesn't allow me to accept whatever the service may send me.

One specific case I need to be able to handle is incoming "application/json" GET requests with no body. How can I achieve this despite Odoo's heavy handed JSON-RPC handing?

Avatar
Discard
Author

None of the resources are helpful. However, the source of the OCA `base_rest` module has some clues at how this could be solved.

Author Best Answer

This was mean't to be a comment, but I don't have enough karma to delete it or switch it to a comment, so I've had to just edit it. System design 10/10.

Avatar
Discard
Related Posts Replies Views Activity
1
Jun 22
4011
1
Aug 20
6396
0
May 21
3815
3
Aug 20
20014
0
Feb 19
2059