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

Base rest : allow return an http error (404, ...)

Open fmdl opened this issue 2 years ago • 1 comments

With base_rest, it is not possible to return a specific error like 404, 201, ...

it is only return 500 by raise UserError

It is possible to manage the return error ?

fmdl avatar Mar 04 '22 10:03 fmdl

You can like this:

from odoo.http import Response
from http import HTTPStatus

...

def get():
    return Response(status=HTTPStatus.NOT_FOUND)

MatiasConTilde avatar Aug 25 '22 20:08 MatiasConTilde