跳至内容
菜单
此问题已终结
2 回复
11830 查看

I'm wondering what is the difference between endpoints in Odoo API. To my knowledge there are three:

  • http://....../xmlrpc

  • http://....../jsonrpc

  • http://....../web/dataset

We can send for example search_read request with each of them and they all are similar.


For example we can send request to "xmlrpc/2/object" using RPC function "execute_kw"
Or we can send request to "jsonrpc" with method "execute"
Or we can send request to "/web/dataset/call_kw" and so on...


I couldn't find comprehensive explanation why is that. What would the best way of sending request.



形象
丢弃

Did you find out about this? I'm also wondering about it, and cannot find documentation.

最佳答案

They are all basically the same thing to the fact that they are just wrappers for the Odoo internal API, but these wrappers are slightly different in how the protocols work:

/xmlrpc is for RPC calls where the POST body must be XML; credentials are part of the POST

/jsonrpc is for RPC calls where the POST body must be JSON; credentials are part of the POST

/web/dataset is for RPC calls where the POST body must be JSON and is basically the same as /jsonrpc except that the TOKENIZED credentials are passed in the session_id cookie; this makes it the proper API to use in a web based application, provided that its running under the exact same host-name, so that you don't have CORS headaches. In this scenario, you typically have a reverse proxy running your web app under some specific path on the server. For example odoo.example.com/odoo might serve your standard Odoo deployment, but odoo.example.com/vuejs might serve your Single Page Application. Since they are both under "odoo.example.com" ... no CORS preflight checks are made.

Both /xmlrpc and /jsonrpc are ideal for code that will NOT run in the browser regardless of the programming language used, but I recommend JSON-RPC since its much lighter than XML. So for example, if you are writing Python scripts for ETL purposes, then you should use the JSON-RPC API.

There is some other nuance with /web/dataset vs the other 2. If you need consulting, please feel free to email me: mike at idaz dot co (not .com)

形象
丢弃
相关帖文 回复 查看 活动
0
2月 25
668
3
1月 23
6094
1
3月 22
4376
1
2月 22
4360
0
10月 20
4063