rest-framework
rest-framework copied to clipboard
In odoo14, the response is always 404 NOT FOUND
class MyRestController(main.RestController):
_root_path = '/my_library_api/'
_collection_name = "my_library.services"
_default_auth = "public"
from odoo.addons.base_rest import restapi
from odoo.addons.component.core import Component
class PingService(Component):
_inherit = 'base.rest.service'
_name = 'ping.service'
_usage = 'ping'
_collection = 'my_library.services'
@restapi.method(
[(["/<int:id>/get", "/<int:id>"], "GET")],
output_param=restapi.CerberusValidator("_get_partner_schema"),
auth="public"
)
def get(self, _id):
return {"name": self.env["res.partner"].sudo().browse(_id).name}
def _get_partner_schema(self):
return {
"name": {"type": "string", "required": True}
}
Even if the auth is public and I add the --db=filter, i cannot access my api. But if I use /web/session/authentication to get a session_id first, I can access the api.
Anyone can help?
try open http://localhost:8069/web/database/manager in Incognito mode
you see only one database ?
It happens the same to me. If I have more than one database, Odoo returns a 404 error.
If in database/manage appear only one database, the problem is solved
anyway we can solve this? my server have a few db
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.