add multipart/form-data
phgas opened this issue · comments
with requests it's:
payload={'key_1': 'one','key_2': '2'}
response = requests.post(url, data=payload, files=[])
EDIT: possibility to change boundary in header/payload is recommended
see https://stackoverflow.com/questions/12385179/how-to-send-a-multipart-form-data-with-requests-in-python
Semi-beautiful Solution:
from requests_toolbelt.multipart.encoder import MultipartEncoder
mp_encoder = MultipartEncoder(
fields={
'foo': 'bar'
}
)
mp_encoder.to_string()
mp_encoder.content_type
Were you able to do it?