Skip to Content
Menu
This question has been flagged

I have created an API for creating a ticket. I just started working on it.

I am getting an error. When I access the API I select the related database and in that database, if my module is installed then I get the response. 
But If I open the URL in incognito mode of the browser then It gives me the error. because the database is not selected by default in incognito mode


Here is the code of the controller file

from odoo import http
from odoo.http import request
import json


class MetaWithHelpdesk(http.Controller):

@http.route('/api/create_ticket', type='http', auth='public', methods=['POST', 'GET'], csrf=False)
def create_ticket(self, **kw):
print('reached')
try:
return json.dumps({'message': 'Ticket created successfully'})
except Exception as e:
return json.dumps({'error': str(e)})


here is the code of __manifest__.py

# -*- coding: utf-8 -*-
{
'name': "Helpdesk Ticket",

'summary': """
Helpdesk Ticket"""
,

'description': """
Helpdesk Ticket
"""
,

# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/16.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
'category': 'helpdesk',
'version': '16.0.1',

# any module necessary for this one to work correctly
'depends': ['base', 'web'],
'auto_install': True,
'bootstrap': True, # load translations for login screen,
'license': 'LGPL-3',
# always loaded
'data': [
# 'security/ir.model.access.csv',
'views/views.xml',
],
}



Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
0
sep 23
1943
0
jún 22
2604
3
máj 21
13300
2
dec 24
1223
1
aug 24
1464