2012-07-09 44 views

回答

14

原来是一个窗户的东西与cURL。

  1. JSON数据应该用双引号(“”)而不是单引号引起来。
  2. 所有的JSON数据包中的双引号必须用反斜线(\)

如进行转义:那么,这样的:

curl --dump-header - -H "Content-Type: application/json" -X POST --data '{"body": "This will prbbly be my lst post.", "pub_date": "2011-05-22T00:46:38", "slug": "another-post", "title": "Another Post", "user": "/api/v1/user/1/"}' http://localhost:8000/api/v1/entry/

应该是:

curl --dump-header - -H "Content-Type: application/json" -X POST --data "{\"body\": \"This will prbbly be my lst post.\", \"pub_date\": \"2011-05-22T00:46:38\", \"slug\": \"another-post\", \"title\": \"Another Post\", \"user\": \"/api/v1/user/1/\"}" http://localhost:8000/api/v1/entry/

+1

感谢您更新此答案,我有完全相同的问题! – 2012-09-25 08:06:41