如何修复 requests.put 方法,因为它显示状态错误代码 500?

问题描述

我正在尝试将 http 请求从客户端发送到我正在更新页面的服务器。我尝试使用虚拟 html 代码测试我的 requests.put 方法是否有效,并且确实如此。这是我使用的有效的虚拟代码

imports requests
from requests.auth import HTTPBasicAuth

headers = {
    'Content-Type': 'application/json',}
pass_string = "<p>This is the updated text for the new page. Created Automatically through script. Experiment successful.</p>"
data = '{"id":"525424594","type":"page","title":"Update Status","space":{"key":"CSSFW"},"body":{"storage":{"value":"' + pass_string + '","representation":"storage"}},"version":{"number":17}}'
response = requests.put('https://confluence.ai.com/rest/api/content/525424594',headers=headers,data=data,auth=HTTPBasicAuth('svc-Automation@ai.com','AIengineering1@ai'))

但是一旦我使用了我想为我的任务传递的 html 字符串,我就会收到一个错误状态代码 500,指出“内部服务器错误”。这是我的代码

imports requests
from requests.auth import HTTPBasicAuth
from bs4 import BeautifulSoup

pass_string = "<p><br /></p><table><colgroup><col /><col /><col /><col /><col /><col /></colgroup><tbody><tr><th><p>JIRA</p></th><th><p>Type</p></th><th><p>PR</p></th><th><p>Commit</p></th><th><p>Author</p></th><th><p>Date</p></th></tr><tr><td><p>IAP-5742</p></td><td><p>Action-item</p></td><td><p><br /></p></td><td><p><br /></p></td><td><p><br /></p></td><td><p><br /></p></td></tr><tr><td><p>IAP-5991</p></td><td><p>Action-item</p></td><td><p><br /></p></td><td><p><br /></p></td><td><p><br /></p></td><td><p><br /></p></td></tr><tr><td><p>IAP-5971</p></td><td><p>Action-item</p></td><td><p><br /></p></td><td><p><br /></p></td><td><br /></td><td><p><br /></p></td></tr><tr><td><p>IAP-6200</p></td><td><p>Action-item</p></td><td><p><br /></p></td><td><p><br /></p></td><td><br /></td><td><p><br /></p></td></tr><tr><td><p>IAP-5608</p></td><td><p>Action-item</p></td><td><p><br /></p></td><td><p><br /></p></td><td><br /></td><td><br /></td></tr><tr><td><p>IAP-5075</p></td><td><p>Action-item</p></td><td><p><br /></p></td><td><p><br /></p></td><td><br /></td><td><p><br /></p></td></tr><tr><td><p>IAP-5757</p></td><td><p>Bug</p></td><td><p><br /></p></td><td><p><br /></p></td><td><br /></td><td><br /></td></tr></tbody></table><p class=\"auto-cursor-target\"><br /></p>"

headers = {
    'Content-Type': 'application/json',}

data = '{"id":"525424594",'AIengineering1@ai'))

请注意,pass_string 是直接从网站的 rest/api/content 输出复制而来的,即从 https://confluence.ai.com/rest/api/content/525424594?expand=body.storage 复制,因此字符串应该没有任何问题,但仍然显示错误代码500,我无法理解它为什么这样做。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...