简体   繁体   English

如何发送带有请求的“多部分/表单数据”,Python 中没有文件

[英]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.

相关问题 如何在python中发送带有请求的“multipart/form-data”? - How to send a “multipart/form-data” with requests in python? 如何在 python 中发送带有请求的“multipart/form-data”? - How to send a "multipart/form-data" with requests in python? 想要发送包含图像的multipart / form-data和python请求 - Want to send a multipart/form-data including images with python requests 无法通过python请求模块发送`multipart / form-data`请求 - Unable to send `multipart/form-data` request with python requests module 使用 POST 请求发送多部分/表单数据字符串,python - Send multipart/form-data string with POST requests, python 在Python请求上没有文件的multipart / form-data请求 - multipart/form-data request with no files on Python Requests 如何使用python中的POST请求在multipart/form-data中发送excel文件? - How to send excel file in multipart/form-data with POST Requests in python? 如何使用 python 请求在媒体组中发送带有 multipart/form-data 的照片? - How to send photos with multipart/form-data in media group with python requests? 如何使用请求在 Python 中发布多部分/表单数据 - How to POST multipart/form-data in Python with requests 如何将文件发布到多部分/表单数据? - How to post files to a multipart/form-data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM