【发布时间】:2021-09-01 04:46:39
【问题描述】:
代码 -odoo 13 自定义模块
以 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
【问题讨论】:
-
让你的问题更清楚stackoverflow.com/help/how-to-ask.
-
该消息只是因为您向 Odoo 发送了错误的 Json 格式。你能告诉我Json通过了吗?