Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4114 Widoki

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




Awatar
Odrzuć
Najlepsza odpowiedź

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





Awatar
Odrzuć
Autor

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

Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

what do you mean by a single db in the instance

Powiązane posty Odpowiedzi Widoki Czynność
0
kwi 17
3081
0
wrz 24
1183
1
mar 15
272
1
lip 25
2184
1
lis 23
11990