【问题标题】:Odoo 13 - json api giving invalid json data errorOdoo 13 - json api 给出无效的 json 数据错误
【发布时间】: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

【问题讨论】:

标签: python json odoo rest


【解决方案1】:

你返回 dict...

尝试返回json.dumps(your_dict)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-28
    • 1970-01-01
    相关资源
    最近更新 更多