Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call odoo controller through Postman

Tags:

odoo

postman

I'm getting stuck when trying to test a router by calling from Postman

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

and calling in postman with header application/json

http://127.0.0.1:8070/nails/login

but log always return

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 -
like image 601
Phong Vy Avatar asked Oct 30 '25 10:10

Phong Vy


2 Answers

Before calling any API, you have to login using /web/session/authenticate using post request. The reason for the above error is odoo is not able to find session information, therefore unable to find which database to login. Sample request type:

{
  "params": {
    "login": "admin",
    "password": "admin",
    "db": "odoo10"
  }
}
like image 129
Kiran Avatar answered Nov 02 '25 15:11

Kiran


Finally I resolved it by adding this in configuration file, ever try but not sure why it's not working before that..

[options]
dbfilter = my_db_name
like image 23
Phong Vy Avatar answered Nov 02 '25 14:11

Phong Vy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!