Python-Tls-Client icon indicating copy to clipboard operation
Python-Tls-Client copied to clipboard

add multipart/form-data

Open phgas opened this issue 1 year ago • 3 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

phgas avatar May 02 '23 17:05 phgas

Semi-beautiful Solution:

from requests_toolbelt.multipart.encoder import MultipartEncoder


mp_encoder = MultipartEncoder(
    fields={
        'foo': 'bar'
    }
)

mp_encoder.to_string()
mp_encoder.content_type

phgas avatar May 02 '23 19:05 phgas

Were you able to do it?

adiazma avatar Jan 20 '24 22:01 adiazma

As @phgas already mentioned: Check this #93

You need to submit data = your_multipart_encoded_object.to_string().decode('utf-8')

OculusVisionSellix avatar Jun 10 '24 11:06 OculusVisionSellix