Last active
December 25, 2015 13:39
-
-
Save sigmavirus24/6985378 to your computer and use it in GitHub Desktop.
multipart/form-data in requests without files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from requests.packages.urllib3.filepost import encode_multipart_formdata | |
data = { | |
'form-field-0': 'value', | |
'form-field-1': 'value', | |
# ... | |
} | |
body, content_type_header = encode_multipart_formdata(fields=data) | |
r = requests.post(url, headers={'Content-Type': content_type_header}, data=body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment