google app engine - HttpClient not POST-ing data to backend server- javascript -
i trying post data web server (google app engine) windows phone using javascript. request reaching server, values going null.
the post request:
var payload = '{"type":"a","make":"b","model":"c","year":"1990"}'; //uri var uri = new windows.foundation.uri(uristring); //ihttpclient var stringcontent = windows.web.http.httpstringcontent(payload, windows.storage.streams.unicodeencoding.utf8, 'application/json'); httpclient.postasync(new windows.foundation.uri(uri), stringcontent); if make properties required=false null. if make required=true badvalueerror: entity has uninitialized properties: vehicle_type, make, model, year
class vehicle(ndb.model): vehicle_type = ndb.stringproperty(required=false) make = ndb.stringproperty(required=false) model = ndb.stringproperty(required=false) year = ndb.stringproperty(required=false) the goal have new vehicle added datastore such:
{"keys": 6212341628665856, "make": "dodge", "vehicle_type": "suv", "model": "caravan", "year": "1999"} if use curl call server works fine:
curl -x post --data-urlencode "type=suv" --data-urlencode "make=dodge" --data-urlencode "model=caravan" --data-urlencode "year=1999" myurl all appreciated
try use logging module , see whether values receive in backend correct or not.
first of import logging module.
import logging second thing, need use logging module see whether values in backend upto mark. suppose have webapp2.requesthandler as
import webapp2 class getcarinfo(webapp2.requesthandler): def get(self): #or post #show values in gae sdk console logging.info(self.request) #or logging.info(self.request.get('<your payload object key>')) #your entity creation(ndb put) code here. app = webapp2.wsgiapplication([ ('/add_car_info', getcarinfo) ], debug=true) once able see correct info being passed javascript client. can proceed further else need figure out what's wrong javascript client(ajax request) or payload passing.
hope you.!
Comments
Post a Comment