Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
3701 Vistas

i tested it using postman and it doesn't work

test_controller.py:

from odoo import http
from odoo.http import request, Response
import json


class TestController(http.Controller):

@http.route("/test", auth='public', type='jsonrpc', csrf=False, method='GET')
def get_test(self, **kw):
print("Test")
response = {'message': "Test Test 123"}
return Response(json.dumps(response), content_type='application/json')
__init__.py:
from . import test_controller

both files are in a folder called controllers




Avatar
Descartar
Mejor respuesta

try this way:
test_controller.py:
from odoo import http

from odoo.http import request

import json


class TestController(http.Controller):


@http.route("/test", auth='public', type='json', csrf=False, methods=['GET'])

def get_test(self, **kw):

print("Test")

response = {'message': "Test Test 123"}

return request.make_response(json.dumps(response), headers={'Content-Type': 'application/json'})


init.py:
from . import test_controller





Avatar
Descartar
Autor

didn't work do you want my file structure ? maybe it helps ?

Mejor respuesta

Hi,

Change the type as json and trigger the end point from the post man and see if it makes any difference. Also try to keep a single db in the instance, if you have multiple use a db filter.


Thanks

Avatar
Descartar
Autor

what do you mean by a single db in the instance

Publicaciones relacionadas Respuestas Vistas Actividad
0
abr 17
2842
0
sept 24
843
1
mar 15
272
0
jun 24
1695
1
nov 23
11070