Python Forum
Curl command to python requests - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Curl command to python requests (/thread-17477.html)



Curl command to python requests - pythonclass - Apr-12-2019

Hello. I am very new to python and would appreciate some help with the following. I have this curl command which works fine:
curl --cacert C:\cacert.pem -u user:key -F "[email protected]" https://serverurl/users/pictures
I converted the curl command to:
picture = {
	'data' : ('picture',open('picture.jpg','rb'))
}
req = requests.post('https://serverurl/users/pictures',files=picture, auth=('user','key'))
I get 200 response but the picture does not get uploaded to the server. Not sure what I am missing. Thank you!