【问题标题】:How to retrieve the json data sending via curl in Django Tastypie?如何在 Django Tastypie 中检索通过 curl 发送的 json 数据?
【发布时间】:2014-03-07 09:04:30
【问题描述】:

我正在通过 curl 命令发送 json 数据。如何找回?

这是我的curl 命令

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

这是我的看法

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"),
               ]

它不打印我的 json 数据。相反,它会抛出一个错误,说

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

如何检索我的 json 数据?

【问题讨论】:

    标签: json django curl tastypie


    【解决方案1】:

    我按照这个命令打印 request.body

    【讨论】:

      猜你喜欢
      • 2016-07-03
      • 1970-01-01
      • 1970-01-01
      • 2015-03-30
      • 2015-01-31
      • 2014-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多