I want to upload a file with pcloud here is my code :
import requests
url = 'https://api.pcloud.com/uploadfile'
path = 'C:\\Users\\MyName\\Desktop\\Folder\\log.txt'
files = {open(path, 'rb')}
data = {'username': '[email protected]', 'password': 'mypassword'}
r = requests.post(url, files=files, data=data)
print(r.text())
I have got the following issue:
ValueError: not enough values to unpack (expected 2, got 0)
files
should be dictionary but you created set()
- (both uses {}
to create instance)
files = {'file': open(path, 'rb')}
BTW: you have to use r.text
without ()
.
Or r.json()
with ()
to get result as Python's dictionary.