Search code examples
jsondjangocurltastypie

How to retrieve the json data sending via curl in Django Tastypie?


I'm sending a json data via curl command. How do I retrieve it back ?

Here is my curl command

 curl -XPOST -i -g http://localhost:8000/api/v1/controllers/register/ -H "content-type: application/json" -d '{"installation_id": 1, "name":"xyz"}'

Here is my view

def api_controllers_register(self,bundle,**kwargs):
        print "bundle",bundle.data

prepend_url

def prepend_urls(self):
        return [
            url(r"^(?P<resource_name>%s)/lastevent%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('api_controllers_register'), name="api_controllers_register"),
               ]

It doesn't print my json data. Instead it throws an error saying

"'WSGIRequest' object has no attribute 'data'",

How do I retrieve my json data?


Solution

  • I followed this command print request.body