【发布时间】:2019-11-14 11:25:05
【问题描述】:
我想从 odoo 控制器发送 json 数据。为此我在控制器下面创建了
from odoo.http import Response
import json
@http.route('/api/json_get_request',auth='public',type='json',methods=["GET"],csrf=False)
def printjson(self,**kw):
headers={'content-type':'application/json'}
return Response(json.dumps({"test":"json string"}),headers=headers)
但在邮递员中访问http://localhost:8089/api/json_get_request 给了我无效的 json 数据,然后我在该响应标头中检查了邮递员控制台 -> Content-Type: "text/html" 显示。 不明白json类型的数据发送后为什么没有收到json数据。
在邮递员上以 http 请求访问 http://localhost:8089/api/json_get_request 后,我得到了正确的 json 数据。 请给我建议 提前致谢
【问题讨论】:
标签: json api controller postman odoo