{"id":621,"date":"2020-09-03T02:21:08","date_gmt":"2020-09-02T20:21:08","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=621"},"modified":"2020-09-03T02:21:08","modified_gmt":"2020-09-02T20:21:08","slug":"odoo-controller-json-route-returns-404-werkzeug-exceptions-notfound","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/odoo-controller-json-route-returns-404-werkzeug-exceptions-notfound.html","title":{"rendered":"Odoo Controller JSON Route Returns 404 &#8211; werkzeug.exceptions.NotFound"},"content":{"rendered":"\n<p>Even though, if you have defined your routes properly, you are seeing an error of the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"id\": null,\n    \"jsonrpc\": \"2.0\",\n    \"error\": {\n        \"http_status\": 404,\n        \"code\": 404,\n        \"data\": {\n            \"name\": \"werkzeug.exceptions.NotFound\",\n            \"debug\": \"Traceback (most recent call last):\\n  File \\\"\/opt\/odoo\/odoo12\/odoo\/http.py\\\", line 656, in _handle_exception\\n    return super(JsonRequest, self)._handle_exception(exception)\\n  File \\\"\/opt\/odoo\/odoo12\/odoo\/http.py\\\", line 314, in _handle_exception\\n    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])\\n  File \\\"\/opt\/odoo\/odoo12\/odoo\/tools\/pycompat.py\\\", line 87, in reraise\\n    raise value\\n  File \\\"\/opt\/odoo\/odoo12\/odoo\/http.py\\\", line 1460, in _dispatch_nodb\\n    func, arguments = self.nodb_routing_map.bind_to_environ(request.httprequest.environ).match()\\n  File \\\"\/opt\/odoo\/odoo12-venv\/lib64\/python3.5\/site-packages\/werkzeug\/routing.py\\\", line 1563, in match\\n    raise NotFound()\\nwerkzeug.exceptions.NotFound: 404: Not Found\\n\",\n            \"message\": \"404: Not Found\",\n            \"exception_type\": \"internal_error\",\n            \"arguments\": []\n        },\n        \"message\": \"404: Not Found\"\n    }\n}<\/pre>\n\n\n\n<p>This error doesn&#8217;t return when you use the http.route as type &#8216;http&#8217; or default, which is still  http, but returns when you use the type &#8216;json&#8217;. One of the cause why the error return is that, you have multiple Odoo databases and Odoo is failing to detect the usable database for the type json. For the type, http, Odoo usually can predict what to use, while for the type json, it can not. For such cases, you would need to use the &#8216;db-filter&#8217; to add the default database to load for Odoo on the odoo-bin command. If you are using the systemd service file, append the line with the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">--db-filter=^my_prod$<\/pre>\n\n\n\n<p>where &#8216;my_prod&#8217; is your database name. <\/p>\n\n\n\n<p>So the service ExecStart would look like the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ExecStart=\/usr\/bin\/scl enable rh-python35 -- \/opt\/odoo\/odoo12-venv\/bin\/python3 \/opt\/odoo\/odoo12\/odoo-bin -c \/etc\/odoo.conf --limit-time-real 1009999999 --limit-time-cpu 1009999999 --limit-memory-hard 89179869184000000 --limit-memory-soft 57179869184000000 --db-filter=^my_prod$<\/pre>\n\n\n\n<p>After making the change, reload your systemctl and restart your odoo-bin:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl daemon-reload\nservice odoo12 restart<\/pre>\n\n\n\n<p>This should do the job. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Even though, if you have defined your routes properly, you are seeing an error of the following: This error doesn&#8217;t return when you use the http.route as type &#8216;http&#8217; or default, which is still http, but returns when you use the type &#8216;json&#8217;. One of the cause why the error return is that, you have &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/odoo-controller-json-route-returns-404-werkzeug-exceptions-notfound.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Odoo Controller JSON Route Returns 404 &#8211; werkzeug.exceptions.NotFound&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[461,292,271,293],"tags":[465,462,463,299,464,297,298],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/621"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=621"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/621\/revisions"}],"predecessor-version":[{"id":622,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/621\/revisions\/622"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}