python 2.7 - can not read post data in app engine -


i'm trying post data app engine in following manner:

sendmessage = function(path, data) {     $.ajax({         type: "post",          url: path,          data: data,          contenttype: "application/json",         datatype: "json",         failure: function(errmsg) {              alert(errmsg);         },         success: function(result,status,xhr){             alert(result);         }     }); }; sendmessage('/chatmessage', {"message": "aaaa"}); 

the receiving code:

class chatmessage(webapp2.requesthandler):      def post(self):         user = users.get_current_user()         message = self.request.get("message", "fail")         logging.error('requestbody:' + str(self.request.body))         logging.error('message:' + message) 

the log messages:

error    2013-05-18 16:23:31,954 channels.py:52] requestbody:message=aaaa error    2013-05-18 16:23:31,956 channels.py:53] message:fail info     2013-05-18 18:23:31,983 server.py:585] default: "post /chatmessage http/1.1" 200 2 

obviously message got on server intact since says message=aaaa why can't "get" message request?

when issue post request, can either encode data url, or put data in body of request.

request.get() urlencoded parameters in url.

in case, putting data in body of request, working properly. if want data, should parse request body.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -