通过Postman调用odoo控制器

4dc9hkyq  于 2023-03-08  发布在  Postman
关注(0)|答案(2)|浏览(286)

我在尝试通过从Postman呼叫来测试路由器时卡住

@http.route('/nails/login', type='json', auth="public")
    def api_login(self, csrf=False, **kwargs):

并使用头文件application/json调用 Postman

http://127.0.0.1:8070/nails/login

但日志总是返回

2018-07-02 14:30:38,123 26497 ERROR ? odoo.http: Exception during JSON request handling.
Traceback (most recent call last):
   File "/home/ryu/odoo/odoo-server/odoo/http.py", line 640, in _handle_exception
     return super(JsonRequest, self)._handle_exception(exception)
   File "/home/ryu/odoo/odoo-server/odoo/http.py", line 1453, in _dispatch_nodb
    func, arguments = self.nodb_routing_map.bind_to_environ(request.httprequest.environ).match()
   File "/usr/local/lib/python2.7/dist-packages/werkzeug/routing.py", line 1573, in match
     raise NotFound()
NotFound: 404 Not Found: The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.
2018-07-02 14:30:38,128 26497 INFO ? werkzeug: 127.0.0.1 - - [02/Jul/2018 14:30:38] "POST /nails/login HTTP/1.1" 200 -
iezvtpos

iezvtpos1#

在调用任何API之前,您必须使用post请求使用/web/session/authenticate登录。出现上述错误的原因是odoo无法找到会话信息,因此无法找到要登录的数据库。示例请求类型:

{
  "params": {
    "login": "admin",
    "password": "admin",
    "db": "odoo10"
  }
}
dphi5xsq

dphi5xsq2#

最后我解决了它添加到配置文件中,曾经尝试,但不知道为什么它不工作之前..

[options]
dbfilter = my_db_name

相关问题