rest-framework icon indicating copy to clipboard operation
rest-framework copied to clipboard

In odoo14, the response is always 404 NOT FOUND

Open lihaotong100 opened this issue 3 years ago • 3 comments

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?

lihaotong100 avatar May 28 '21 08:05 lihaotong100

try open http://localhost:8069/web/database/manager in Incognito mode

you see only one database ?

whileom-039 avatar Jul 01 '21 07:07 whileom-039

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

flachica avatar Dec 24 '21 12:12 flachica

anyway we can solve this? my server have a few db

budisentosa avatar May 05 '22 05:05 budisentosa

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.

github-actions[bot] avatar Nov 06 '22 12:11 github-actions[bot]