def post(self, token): '''Handles POST requests''' if self.request.content_type == 'application/json': match = re.match(r'^/api/v1$', self.request.path_info) if not match: self.render_error(int(400), 'method_error', 'The only supported POST url is: "/api"') return client_id = token.client_id #Simple: Load the JSON values that were sent to the server newObj = parser.put_model_obj(self.request.body, client_id) if isinstance(newObj, dict): try: self.render_error(int(400), newObj['error'], newObj['error_description']) return except: self.render_error(int(400), 'api_error', 'Invalid Error message for post object') return if not newObj: self.render_error(int(400), 'json_error', "The JSON supplied in your POST request was not valid") return else: self.render_error(int(400), 'invalid_content_type', "All data must be posted using JSON.") return #Write back the id of the new object self.response.write(str(newObj.key.urlsafe()))
def post(self): '''Handles POST requests''' if self.request.content_type == 'application/json': match = re.match(r'^/api$', self.request.path_info) if not match: raise MalformedURLException("The only supported POST url is: '/api'") #Simple: Load the JSON values that were sent to the server newObj = parser.put_model_obj(self.request.body) else: raise MalformedURLException("All data must be posted using JSON. If you want to upload some data, use the file_uploader mechanism.") #Write back the id of the new object self.response.write(str(newObj.key.id()))
def post(self): '''Handles POST requests''' if self.request.content_type == 'application/json': match = re.match(r'^/api$', self.request.path_info) if not match: raise MalformedURLException( "The only supported POST url is: '/api'") #Simple: Load the JSON values that were sent to the server newObj = parser.put_model_obj(self.request.body) else: raise MalformedURLException( "All data must be posted using JSON. If you want to upload some data, use the file_uploader mechanism." ) #Write back the id of the new object self.response.write(str(newObj.key.id()))