콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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?

아바타
취소
작성자

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

작성자 베스트 답변

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.

아바타
취소
관련 게시물 답글 화면 활동
1
6월 22
4642
1
8월 20
7018
0
5월 21
4443
3
8월 20
20720
0
2월 19
2457