import requests
url = "https://192.168.4.103/iof/base/resource/addResourceBf"
payload={'resoId': 'reso_fenlei16568654548266IP134232246455',
'resoName': '1234444455652345',
'resoDesc': '1',
'resTag': '23',
'resoVersion': '123',
'rid': '16686545484141',
'modeType': '0',
'authMode': '1',
'encrypt': '0'}
files=[
('modeFile',('1w.csv',open('C:/Users/hanfe/Desktop/1w.csv','rb'),'text/csv'))
]
headers = {
'Cookie': 'âSecureâ; JSESSIONID=446D97EEB739E13C88FF4C61E23DBF9B'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files,verify=False)
print(response.text)
注意: 通过抓包显示请求头中包括 Content-Type:multipart/form-data,但是调用接口时不要写进去啊,否则会下面错误
Failed to parse multipart servlet request; nested exception is java.io.IOException:标签:files,python,was,request,headers,multipart,org,requests,上传 From: https://blog.51cto.com/asura1992/5860730
org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary
was found org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request;
nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found