这是我的代码:
from odoo import http
_logger = logging.getLogger(__name__)
class CrmController(http.Controller):
@http.route('/crm/lead', type='json', auth='none', website=True, methods=['POST'])
def post_data_end_point(self):
print("==== api called successfully ====")
return "api called successfully---"
在给邮递员打电话后,我收到了这个错误
2022-09-14 09:44:09,925 167674 INFO odoo15 werkzeug: 127.0.0.1 - - [14/Sep/2022 09:44:09] "POST /crm/lead/ HTTP/1.1" 301 - 35 0.020 0.817
2022-09-14 09:44:10,421 167674 INFO odoo15 werkzeug: 127.0.0.1 - - [14/Sep/2022 09:44:10] "GET /crm/lead HTTP/1.1" 404 - 214 0.116 0.357
您定义了type='json'这意味着它只响应json(字典(对象,而不是字符串。