curl-and-python

Re: Tracks Script

From: Kjetil Jacobsen <kjetilja_at_gmail.com>
Date: Mon, 1 Sep 2008 10:46:54 +0200

hi,

try using the '--libcurl' commandline option with the curl command
that works. this will output a c/libcurl version of the corresponding
curl command. set the pycurl options accordingly.

regards,
    - kjetil

On Sun, Aug 31, 2008 at 9:45 PM, Jonathan Chapman <chafnan_at_gmail.com> wrote:
> I am running a a ruby program named tracks. I can use curl to post into the
> program. Here is the command I run that works:
>
> curl -u XXXXXXX:XXXXXXX -H "Content-Type: text/xml" -d
> "<todo><description>Test2</description><context_id>1</context_id></todo>"
> http://server/todos.xml -i
>
> What I am trying to do is have a python script use pycurl to post into the
> program. Here is what I have in my script:
>
> curl = pycurl.Curl()
> curl.setopt(pycurl.URL, "http://server/todos.xml")
> curl.setopt(pycurl.POSTFIELDS,
> "<todo><description>Test2</description><context_id>1</context_id></todo>")
> curl.setopt(pycurl.USERPWD, trlp)
> curl.perform()
> curl.close()
>
> Here is what I am getting on the server logs after I run my script:
>
> Processing TodosController#create (for xxx.xxx.xxx.xxx at 2008-08-31
> 21:27:34) [POST]
> Session ID: 995c0f615b278e93614bbe991ca714d4
> Parameters:
> {"<todo><description>Test2</description><context_id>1</context_id></todo>"=>nil,
> "format"=>"xml", "action"=>"create", "controller"=>"todos"}
>
> Just for reference, here is what the server log looks like after a
> successful entry
>
> Processing TodosController#create (for xxx.xxx.xxx.xxx at 2008-08-31
> 21:24:03) [POST]
> Session ID: 5d7a40af941e56f20d00cf18851e59d4
> Parameters: {"format"=>"xml", "action"=>"create",
> "todo"=>{"context_id"=>"1", "description"=>"Test2"}, "controller"=>"todos"}
>
> Any help would be appreciated.
>
> Thanks,
>
> Jonathan
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2008-09-01