我想使用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/
但它返回以下响应 header ,如下所示:
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”来制作 curl(1) post - 如果您给它一个 --data
参数,它会自动执行此操作。
相反,它会将“POST”误认为是您要发送到的 URL,并且如您想象的那样失败。丢掉这个词,你应该会很好。
关于api - 如何使用curl 通过基本http 身份验证发布JSON 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10963706/