Closed ayust closed 9 years ago
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'}
)