How to send a multipart/form-data
with requests in python? How to send a file, I understand, but how to send the form data by this method can not understand.
Here is the simple code snippet to upload a single file with additional parameters using requests:
url = 'https://'
fp = '/Users/jainik/Desktop/data.csv'
files = {'file': open(fp, 'rb')}
payload = {'file_id': '1234'}
response = requests.put(url, files=files, data=payload, verify=False)
Please note that you don't need to explicitly specify any content type.
NOTE: Wanted to comment on one of the above answers but could not because of low reputation so drafted a new response here.