Postman显示200 OK,但作为响应,它显示odoo API错误?

3htmauhk  于 2023-02-16  发布在  Postman
关注(0)|答案(1)|浏览(277)

我正在点击一个odoo API,它给出了200 ok状态,但在响应中给出了xml错误响应。我还附上了postman x1c 0d1x的截图
我只是按照官方文档的odoo和想要一个响应的服务器版本。**你能告诉我在后的人,我们如何才能得到服务器版本的响应在 Postman 。**https:www.odoo.com/documentation/13.0/webservices/odoo.html#logging-in

主机网址:'https:duduslimmer-odoo-huge-stage-545860.dev.odoo.com',
数据库网址:'duduslimmer-odoo-huge-stage-545860',

我想要这样的回应:

{
    "server_version": "13.0",
    "server_version_info": [13, 0, 0, "final", 0],
    "server_serie": "13.0",
    "protocol_version": 1,
}

但得到的回应是:

<?xml version='1.0'?>
<methodResponse>
    <fault>
        <value>
            <struct>
                <member>
                    <name>faultCode</name>
                    <value>
                        <int>1</int>
                    </value>
                </member>
                <member>
                    <name>faultString</name>
                    <value>
                        <string>Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/addons/base/controllers/rpc.py", line 69, in xmlrpc_2
    response = self._xmlrpc(service)
  File "/home/odoo/src/odoo/odoo/addons/base/controllers/rpc.py", line 48, in _xmlrpc
    params, method = loads(data)
  File "/usr/lib/python3.6/xmlrpc/client.py", line 1019, in loads
    p.feed(data)
  File "/usr/lib/python3.6/xmlrpc/client.py", line 439, in feed
    self._parser.Parse(data, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0
</string>
                    </value>
                </member>
            </struct>
        </value>
    </fault>
</methodResponse>

你能请检查是我的张贴网址正确的手段,我必须提到字'版本'在这个网址太。
发送版本的json主体时得到的响应:Json正文:

{
    "methodCall": {
        "methodName": "version",
        "params": "omi"
    }
}

Json响应:

{
    "jsonrpc": "2.0",
    "id": null,
    "error": {
        "code": 200,
        "message": "Odoo Server Error",
        "data": {
            "name": "werkzeug.exceptions.BadRequest",
            "debug": "Traceback (most recent call last):\n  File \"/home/odoo/src/odoo/odoo/http.py\", line 656, in _handle_exception\n    return super(JsonRequest, self)._handle_exception(exception)\n  File \"/home/odoo/src/odoo/odoo/http.py\", line 314, in _handle_exception\n    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])\n  File \"/home/odoo/src/odoo/odoo/tools/pycompat.py\", line 87, in reraise\n    raise value\n  File \"/home/odoo/src/odoo/odoo/http.py\", line 698, in dispatch\n    result = self._call_function(**self.params)\n  File \"/home/odoo/src/odoo/odoo/http.py\", line 322, in _call_function\n    raise werkzeug.exceptions.BadRequest(msg % params)\nwerkzeug.exceptions.BadRequest: 400 Bad Request: <function RPC.xmlrpc_2 at 0x7f8a69ab3a60>, /xmlrpc/2/common: Function declared as capable of handling request of type 'http' but called with a request of type 'json'\n",
            "message": "400 Bad Request: <function RPC.xmlrpc_2 at 0x7f8a69ab3a60>, /xmlrpc/2/common: Function declared as capable of handling request of type 'http' but called with a request of type 'json'",
            "arguments": [],
            "exception_type": "internal_error"
        }
    }
}
91zkwejq

91zkwejq1#

试试用那个身体:

<?xml version="1.0"?>
<methodCall>
<methodName>version</methodName>
<params/>
</methodCall>

如果您想手动执行此操作,那么https://en.wikipedia.org/wiki/XML-RPC提供了一些关于如何创建XML-RPC请求的信息。
那么端点是/jsonrpc,主体可能是{"service":"common","method": "version", "params": {}},但是JSON API没有很好的文档记录,我从来没有直接使用过它。

相关问题