def create( self, request, id=None ): #called for a POST request #When making a POST request, data has to be sent with the request, same goes with PUT #eg - In jQuery ajax {"a":null} works but {} doesn't #print "GOT CREATE (POST) request on /api/poll/" if not id: #id should always be None here try: question = request.POST.get('question') pub_date = utils.dateFromString(request.POST.get('pubDate')) if question and pub_date: poll = Poll() poll.question = question poll.pub_date = pub_date poll.polling_ended = False poll.save() return poll except Exception, e: resp = rc.BAD_REQUEST resp.write("Error creating 'Poll' object") return resp