Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
4067 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Penulis

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

Jawaban Terbai

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
Buang
Penulis

what do you mean by a single db in the instance

Post Terkait Replies Tampilan Aktivitas
0
Apr 17
3053
0
Sep 24
1138
1
Mar 15
272
1
Jul 25
2143
1
Nov 23
11955