Python Forum
Curl command to python requests
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Curl command to python requests
#1
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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python requests library .JSON() error mHosseinDS86 6 3,406 Dec-19-2022, 08:28 PM
Last Post: deanhystad
  How do loop over curl and 'put' different values in API call? onenessboy 0 1,219 Jun-05-2022, 05:24 AM
Last Post: onenessboy
  how can I correct the Bad Request error on my curl request tomtom 8 5,058 Oct-03-2021, 06:32 AM
Last Post: tomtom
  Python requests oauth2 access token herobpv 6 3,895 Sep-27-2021, 06:54 PM
Last Post: herobpv
  Python Requests SSL Aussie 0 1,993 Jan-07-2021, 02:09 AM
Last Post: Aussie
  Python Requests Aussie 2 2,735 Dec-23-2020, 03:24 AM
Last Post: Aussie
  Python Requests package: Handling xml response soumyarani 1 2,154 Sep-14-2020, 11:41 AM
Last Post: buran
  Python API and requests deep_logic 9 4,303 Jul-29-2020, 03:47 PM
Last Post: ndc85430
  How to save Python Requests data sent to server? RedLeonard 5 4,951 Jul-05-2020, 10:33 AM
Last Post: RedLeonard
  Works with Curl. Can't get it to work in Python bazcurtis 3 2,538 May-07-2020, 07:47 AM
Last Post: bazcurtis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020