Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1607 Lượt xem

Problem Description

I am encountering a "Session expired" error when trying to access my custom API endpoint in Odoo. The endpoint is supposed to return all records from the my_modul model, but I receive an error response stating:

{

    "jsonrpc": "2.0",

    "id": null,

    "error": {

        "code": 100,

        "message": "Odoo Session Expired",

        ...

    }

}


Code Snippet

Here is the relevant code for my API endpoint:

@http.route('/restapi/get-all', auth='user', methods=['GET'])
def get_all(self, **kw):
    try:
        data = request.env['my_modul'].search_read([])
        if not data:
            return error_response(400, "No data found")

        response_data = {
            'success': True,
            'message': 'All patients retrieved',
            'data': data
        }

        return Response(json.dumps(response_data, default=str), status=200, content_type='application/json')

    except Exception as e:
        return error_response(500, f"Server error: {str(e)}")
Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

q

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,
As the authentication is set as user, can you ensure the api is called with a valid session/token
Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 2 22
3566
1
thg 2 22
6322
0
thg 11 21
3990
1
thg 4 25
531
0
thg 12 24
994