Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
3317 Visualizzazioni

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
Abbandona
Autore

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

Autore Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
giu 22
5272
1
ago 20
7544
0
mag 21
4953
3
ago 20
21261
0
feb 19
2825