开发者

Appengine urlfetch debugging

开发者 https://www.devze.com 2023-02-06 07:17 出处:网络
I\'m trying to do what should be a fairly simple url fetch with google appengine. However, it keeps failing.

I'm trying to do what should be a fairly simple url fetch with google appengine. However, it keeps failing.

result = urlfetch.fetch(url=apiurl, method=urlfetch.POST)

I also tried using httplib:

conn = httplib.HTTPConnection("api.eve-online.com")
conn.request("POST", "/char/CharacterSheet.xml.aspx", params, headers)

response = conn.getresponse()
self.response.out.write(response.read())

Both of these return very similar errors,

Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 515, in __call__
    handler.get(*groups)
  File "C:\Users\Martin\Documents\google_appengine\martindevans\eveapi.py", line 24, in get
    method=urlfetch.POST)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch.py", line 241, in fetch
    return rpc.get_result()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 530, in get_result
    return self.__get_result_hook(self)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch.py", line 315, in _get_fetch_result
    rpc.check_success()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 502, in check_success
    self.__rpc.CheckSuccess()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_rpc.py", line 149, in _WaitImpl
    self.request, self.response)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub.py", line 80, in MakeSyncCall
    method(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch_stub.py", line 133, in _Dynamic_Fetch
    deadline=deadline)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch_stub.py", line 223, in _RetrieveURL
    connection.request(method, full_path, payload, adjusted_headers)
  File "C:\Python27\lib\httplib.py", line 946, in request
    self._send_request开发者_StackOverflow中文版(method, url, body, headers)
  File "C:\Python27\lib\httplib.py", line 986, in _send_request
    self.putheader(hdr, value)
  File "C:\Python27\lib\httplib.py", line 924, in putheader
    str = '%s: %s' % (header, '\r\n\t'.join(values))
TypeError: sequence item 0: expected string, int found

I have no idea what's going on here. I'm not providing any sequences to the urlfetch method, so I'm unsure where to start debugging this.

edit: As asked, here are the headers:

headers = { "Content-type": "application/x-www-form-urlencoded" }

This can't be the problem though, because the first approach doesn't even set any headers!


Are you using Python 2.7 ? It supports only 2.5.2. While 2.6 mostly works, 2.7 don't.

0

精彩评论

暂无评论...
验证码 换一张
取 消