Odoo 13 json api提供无效的json数据错误

2024-06-02 04:20:36 发布

您现在位置:Python中文网/ 问答频道 /正文

代码-odoo 13自定义模块

函数返回json格式的数据(RESTAPI)

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


Tags: 模块函数代码fromodooimportjsonfalse