我一个字一个地跟着tastypie教程,直到我到达帖子部分: http://django-tastypie.readthedocs.org/en/latest/interacting.html#creating-a-new-resource-post
当我运行此命令时,我不断收到以下错误:
No JSON object could be decoded
我查了一下,我确信我正在逐字逐句地记录文件。
感谢您的帮助
答案 0 :(得分:16)
原来是cURL的windows事物。
例如:所以,这个:
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/