Non-async get() is broken on AppEngine
Closed this issue · 4 comments
File "/base/data/home/apps/s~evecerts/1.381400983092398120/evelink/api.py", line 510, in wrapper
kw['api_result'] = client.api.get(self.path, params=params)
File "/base/data/home/apps/s~evecerts/1.381400983092398120/evelink/api.py", line 265, in get
response, robj = self.send_request(full_path, params)
File "/base/data/home/apps/s~evecerts/1.381400983092398120/evelink/appengine/api.py", line 87, in send_request
return self.send_request_async(url, params).get_result()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 325, in get_result
self.check_success()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 368, in _help_tasklet_along
value = gen.throw(exc.__class__, exc, tb)
File "/base/data/home/apps/s~evecerts/1.381400983092398120/evelink/appengine/api.py", line 99, in send_request_async
headers=headers,
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 371, in _help_tasklet_along
value = gen.send(val)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/context.py", line 1275, in urlfetch
validate_certificate=validate_certificate)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/urlfetch.py", line 326, in make_fetch_call
request.set_payload(payload)
File "cpp_message.pyx", line 124, in cpp_message.SetScalarAccessors.Setter (third_party/apphosting/python/protobuf/proto1/cpp_message.cc:2229)
TypeError: <type 'dict'> has type <type 'dict'>, but expected one of: str, unicode
Hello! How was this issue resolved? We are having a similar issue on appengine with httplib. We have looked at your commit that closed this issue, which indicated the body of a request must be str
, but after double-checking that we still get this same type-dict exception. Any thoughts you remember?
@ericroberts Check the types of the arguments you're passing to urlfetch
, e.g. the params
argument or other position/keyword arguments. It may be useful to dump their types to a log immediately before you make the call to urlfetch
to double-check. The failure case here was because we weren't urlencode
ing our params
value (since the requests
library expects a dictionary instead).
@ayust thanks! We actually had solved our problem but were accidentally not serving the fixed code. Thank you for your fast response though!
Was just having the same issue with my own appengine project and solved it by json encoding my payload & setting the content type in headers.
import json
from google.appengine.api import urlfetch
urlfetch.fetch(
method=urlfetch.POST,
url=url,
payload=json.dumps(data),
headers={'Content-Type': 'application/json'}
)