擅长:python、mysql、java
<p>您可能不应将数据作为字符串传递,如下所示:</p>
<pre><code>data = '''{
"title": {
"value": "demo",
"type": "Text"
},
"percentage": {
"type": "Text",
"value": "0%"
}'''
</code></pre>
<p>按正常口述传递:</p>
^{pr2}$
<p>请求库将自动为您转换此词典。{{cd2>也不要使用参数。下面请专家从文档中找出原因。在</p>
<pre><code>def post(url, data=None, json=None, **kwargs):
r"""Sends a POST request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
</code></pre>
<p>从你的评论看来,你应该这样传递你的数据:</p>
<p><code>response = requests.post(url, json=data_json, headers=headers)</code></p>
<p>因为您的端点需要json而不是表单编码的字节</p>
<p>结尾处也少了大括号。在</p>