headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, br
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:255
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryAAAuEGgBgQABXetS
Request Payload
------WebKitFormBoundaryAAAuEGgBgQABXetS
Content-Disposition: form-data; name="file"; filename="67.pdf"
Content-Type: application/pdf
------WebKitFormBoundaryAAAuEGgBgQABXetS--
files = {'Filename':'67.pdf',
'file':('67.pdf',open(r'C:\Users\john\Desktop\67.pdf','rb'),'application/octet-stream'),
'Upload':'Submit Query'
}
html=requests.post(url=url,headers=headers,files=files)
print (html.status_code)
print (html.text)
像这样post会报错
TypeError: Cannot read property 'path' of undefined<br> at /u/apps/jibe-apply-app_4.0.41_master/server/routes/api/apply/upload.js:96:33<br> at Layer.handle [as handle_request] (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/layer.js:95:5)<br> at next (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/route.js:131:13)<br> at /u/apps/jibe-apply-app_4.0.41_master/server/middleware/statsd.js:40:7<br> at Layer.handle [as handle_request] (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/layer.js:95:5)<br> at next (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/route.js:131:13)<br> at module.exports (/u/apps/jibe-apply-app_4.0.41_master/server/middleware/requireUser.js:6:5)<br> at Layer.handle [as handle_request] (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/layer.js:95:5)<br> at next (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/route.js:131:13)<br> at Route.dispatch (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/route.js:112:3)<br> at Layer.handle [as handle_request] (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/layer.js:95:5)<br> at /u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:277:22<br> at Function.process_params (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:330:12)<br> at next (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:271:10)<br> at expressInit (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/middleware/init.js:33:5)<br> at Layer.handle [as handle_request] (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/layer.js:95:5)<br> at trim_prefix (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:312:13)<br> at /u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:280:7<br> at Function.process_params (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:330:12)<br> at next (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:271:10)<br> at query (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/middleware/query.js:44:5)<br> at Layer.handle [as handle_request] (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/layer.js:95:5)<br> at trim_prefix (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:312:13)<br> at /u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:280:7<br> at Function.process_params (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:330:12)<br> at next (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:271:10)<br> at Function.handle (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/router/index.js:176:3)<br> at EventEmitter.handle (/u/apps/jibe-apply-app_4.0.41_master/node_modules/express/lib/application.js:173:10)
但是如果把payload里的内容复制下来,粘贴到某个文件,post这个文件,反而不会有这个错误。requests不要post这个文件的内容么?
Done!
files = {
}
That’s it