Python:I get that error while trying ot parse the response of a post request

58 views Asked by At
with open("File.txt", 'rb') as f:
    r = requests.post('https://file.io/?expires=1m', files=f)
print(r.status_code)
print(r)

The site is that one https://www.file.io/, but I get that error.

    too many values to unpack (expected 2)

Can you help me? Thank you.

1

There are 1 answers

0
Ajay Tom George On BEST ANSWER

Yeah I went through the api of file.io, you have submit the data as multipartform data.

Approach 1=Using requests module

multipart_form_data = {
    'file': ('File.txt', open('File.txt', 'rb')),
}

response = requests.post('https://file.io', files=multipart_form_data)

you can change the url to https://file.io/?expires=1w to make it expire in a week

Approch 2-Using Curl

curl -F "[email protected]" https://file.io

F represents multi part form data