HTTP POST File without cURL

David Stanek dstanek at dstanek.com
Wed Sep 9 20:56:16 CEST 2009


On Wed, Sep 9, 2009 at 1:57 PM, John D Giotta<jdgiotta at gmail.com> wrote:
> I'm working with an API that allows me to POST a zip file via HTTP and
> the documentation uses a cURL example. cURL works, but when I try to
> POST the file via python it fails.
> I don't want to use cURL (since I'm trying to be transparent and
> dependency-less), but I can't find anything online that works.
>
> When I use multipart/form-data methods (found here
> http://code.activestate.com/recipes/146306/), the recipient cannot
> decipher the attached file.
>
> This is about the most difficult thing I've had to do with python and
> yet it is supposed to be the very basics of HTTP.
>
> Example cURL command:
> curl -v -u username:passwd --data-binary @/home/jdgiotta/test.zip -H
> "Content-Type: application/zip" https://host/selector
>
> Is there a valid way to do this?
>

Without seeing code it is hard to tell what is happening. What I would
do is capture the HTTP traffic and compare Python to cURL. Then you'll
know how to change you script.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek



More information about the Python-list mailing list