curl-and-python

Tracks Script

From: Jonathan Chapman <chafnan_at_gmail.com>
Date: Sun, 31 Aug 2008 21:45:33 +0200

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
Received on 2008-08-31