问题:上传文件完全按照页面请求头设置,上传接口一直调用不成功
原因:经过尝试,问题出现在请求头"Content-Type": “multipart/form-data”,可以去掉"Content-Type": “multipart/form-data”,尝试,上传成功
import requests
url = "https://lll.com.cn/purser/requirement/file"
# 请求头可以方其他必须参数
headers = {
"Cookie": "cookie",
"Token": "token"
}
files = {"file": open("E:\\ones-api-test\\API_Automation\\Params\\app.js", "rb")}
res = requests.post(url=url, files=files, headers=headers,verify=False)
print(res.text)
图片为上传成功,上边警告消除可以参考另一篇文章处理https://blog.csdn.net/weixin_45728276/article/details/121393958?spm=1001.2014.3001.5501