问题描述
返回json数据的函数(rest api)
from odoo import http
from odoo.http import request,Response
import json
class OpenAcademy(http.Controller):
@http.route('/opentest/',type='json',csrf=False,auth="none",methods=['GET'],)
def update_order_webhook(self):
return {
'success': False,'error': 'no_tx_found',}
Error - <title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>Invalid JSON data: ''</p>
当我明确定义 type="json" 时,也将内容类型返回为 text/html
解决方法
你返回字典...
尝试返回 json.dumps(your_dict)