Api 如何在基本http验证上使用curl发布JSON数据?

Api 如何在基本http验证上使用curl发布JSON数据?,api,rest,curl,Api,Rest,Curl,我想使用curl unix命令发布数据通过谷歌搜索得到的结果如下: curl --dump-header - -H "Content-Type: application/json" -X POST --data '{"description": "This will prbbly be my lst post.", "transaction_id": "2011-05-22T00:46:38", "account": "another-post"}' http://127.0.0.1:8000

我想使用curl unix命令发布数据通过谷歌搜索得到的结果如下:

curl --dump-header - -H "Content-Type: application/json"  -X POST --data '{"description": "This will prbbly be my lst post.", "transaction_id": "2011-05-22T00:46:38", "account": "another-post"}' http://127.0.0.1:8000/api/transaction/
curl: (6) Could not resolve host: POST; nodename nor servname provided, or not known
HTTP/1.0 401 UNAUTHORIZED
Date: Sat, 09 Jun 2012 18:50:37 GMT
Server: WSGIServer/0.1 Python/2.7.1
Content-Type: text/html; charset=utf-8
但其返回的响应标题如下所示:

curl --dump-header - -H "Content-Type: application/json"  -X POST --data '{"description": "This will prbbly be my lst post.", "transaction_id": "2011-05-22T00:46:38", "account": "another-post"}' http://127.0.0.1:8000/api/transaction/
curl: (6) Could not resolve host: POST; nodename nor servname provided, or not known
HTTP/1.0 401 UNAUTHORIZED
Date: Sat, 09 Jun 2012 18:50:37 GMT
Server: WSGIServer/0.1 Python/2.7.1
Content-Type: text/html; charset=utf-8
我做错了什么

你不需要写“POST”来制作POST——如果你给它一个
--data
参数,它会自动完成

相反,它将“POST”误认为是您要发送到的URL,并如您所想象的那样失败。扔掉那个词,你就应该很好了。

你不需要写“POST”来写POST——如果你给它一个
--data
参数,它会自动写出来

相反,它将“POST”误认为是您要发送到的URL,并如您所想象的那样失败。放下那个词,你就应该做个好人