[英]How to send a 'multipart/form-data' with requests, without files in Python
I want to send a 'multipart/form-data' dictionary data without files我想发送一个没有文件的“multipart/form-data”字典数据
headers = {'key':'value', 'Content-Type':'multipart/form-data'}
data = {'api_key':'api_value', ... }
response = request.post('API_URL', headers=headers, data=data)
but API response is:但 API 响应是:
FileUploadException: the request was rejected because no multipart boundary was found
so I changed 'multipart/form-data' -> 'multipart/form-data; boundary=____sample'
所以我改变了'multipart/form-data' -> 'multipart/form-data; boundary=____sample'
'multipart/form-data' -> 'multipart/form-data; boundary=____sample'
This code also didn't work. 'multipart/form-data' -> 'multipart/form-data; boundary=____sample'
此代码也不起作用。 It didn't recognize the parameters.它无法识别参数。
How can I send 'multipart/form-data' requests without files?如何发送没有文件的“multipart/form-data”请求?
I'm not entirely sure how python works with requests.我不完全确定 python 如何处理请求。 You can try this accepted answers or any which is suitable您可以尝试这个公认的答案或任何合适的答案
python requests - POST Multipart/form-data without filename in HTTP request python 请求 - 在 HTTP 请求中发布没有文件名的多部分/表单数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.