Page 1 of 1

[ANSWERED]: curl -X command convert to urllib2

Posted: Thu Apr 30, 2015 11:54 am
by kw123
i have the following curl command that works:

curl http:.... -H "authorization: Token xxx" -X DELETE

I have not been able to incorporate the -X DELETE into a urllib2 call. The authorization is ok. It goes into the header ={ "authorization": "token 1212341234"}.

but the -X DELETE is not in the form "xx:yy"

Any hint how to get this into URLIB2 would be appreciated. I have been searching on the web for several hours, but no luck..

thanks

Karl


curl reference
-X, --request <command>

(HTTP) Specifies a custom request method to use when communicating with the HTTP server. The specified request method will be used instead of the method otherwise used (which defaults to GET). Read the HTTP 1.1 specification for details and explanations. Common additional HTTP requests include PUT and DELETE, but related technologies like WebDAV offers PROPFIND, COPY, MOVE and more. .....

at [urlhttp://curl.haxx.se/docs/manpage.html][/url]

Re: curl -X command convert to urllib2

Posted: Thu Apr 30, 2015 7:41 pm
by matt (support)
Take a look at this blog thread, or you might want to consider using Requests since it supports all the HTTP verbs.. I've never used Requests, but it looks nice and I think it will run on Python 2.6.