tags:

views:

28

answers:

2

I have a problem with importing file to calendar over wcap protocol. In documentation http://docs.sun.com/source/816-6416-10/pr10WCAP.html#26125 is said that i should use POST method. I have trayed but with no positiv result. I have no idea hov to forced it to work with python

A: 

The wcap reference you provide contains example POST data. Using the urllib2.urlopen() function with POST data is straightforward.

urllib2.urlopen(url[, data][, timeout])

Open the URL url, which can be either a string or a Request object.

data may be a string specifying additional data to send to the server, or None if no such data is needed. Currently HTTP requests are the only ones that use data; the HTTP request will be a POST instead of a GET when the data parameter is provided. data should be a buffer in the standard application/x-www-form-urlencoded format. The urllib.urlencode() function takes a mapping or sequence of 2-tuples and returns a string in this format.

gimel
A: 

ok thats again me this is what i have wrote

import urllib2
data =  urllib.urlencode([('qery', tmp)])
req = urllib2.Request("http://kalendarz.pwr.wroc.pl")
urllib2.urlopen(req, data)

tmp is srting which contains modyfied POST message example form http://docs.sun.com/source/816-6416-10/pr10WCAP.html#26125 (i changed id_session and login) but it still does not work. This is a error:

Traceback (most recent call last): File "./gniazda.py", line 109, in main() File "./gniazda.py", line 92, in main urllib2.urlopen(req, dane) File "/usr/lib/python2.6/urllib2.py", line 124, in urlopen return _opener.open(url, data, timeout) File "/usr/lib/python2.6/urllib2.py", line 389, in open response = self._open(req, data) File "/usr/lib/python2.6/urllib2.py", line 407, in _open '_open', req) File "/usr/lib/python2.6/urllib2.py", line 367, in _call_chain result = func(*args) File "/usr/lib/python2.6/urllib2.py", line 1146, in http_open return self.do_open(httplib.HTTPConnection, req) File "/usr/lib/python2.6/urllib2.py", line 1119, in do_open r = h.getresponse() File "/usr/lib/python2.6/httplib.py", line 974, in getresponse response.begin() File "/usr/lib/python2.6/httplib.py", line 391, in begin version, status, reason = self._read_status() File "/usr/lib/python2.6/httplib.py", line 355, in _read_status raise BadStatusLine(line) httplib.BadStatusLine

What I do wrong?

kolo