Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
4323 Ansichten

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
Verwerfen
Beste Antwort

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
Verwerfen
Autor

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

Beste Antwort

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
Verwerfen
Autor

what do you mean by a single db in the instance

Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Apr. 17
3225
0
Sept. 24
1355
1
März 15
272
1
Juli 25
2433
1
Nov. 23
12203