我的問題: 使用命令行工具在我的POST請求發送一些數據的同時捲曲我的本地主機服務器不起作用。WINDOWS RESTful服務的cURL POST命令行
什麼似乎會導致錯誤: 想象這樣的事情
curl -i -X POST -H 'Content-Type: application/json' -d '{"data1": "data goes here", "data2": "data2 goes here"}' http:localhost/path/to/api
返回數據的結果
curl: (6) Could not resolve host: application; No data record of requested type
curl: (6) Could not resolve host: data goes here,; No data record of requested type
curl: (6) Could not resolve host: data2; No data record of requested type
curl: (3) [globbing] unmatched close brace/bracket at pos 16
經過一番搜索我想通了那個問題不可能是用於t的sintax他請求,因爲它在UNIX shell上工作。
Are you possibly using Windows? That so looks like a completely broken shell that doesn't properly deal with single-quotes vs double-quotes. I just tried that command line and it worked fine on my linux box. http://curl.haxx.se/mail/archive-2011-03/0066.html
我試圖解決與 「逃了\」,但它仍然沒有奏效
2.
curl -i -X POST -H 'Content-Type: application/json' -d '{\"data1\": \"data goes here\", \"data2\": \"data2 goes here\"}' http: //localhost/path/to/api
3.
curl -i -X POST -H 'Content-Type: application/json' -d '{\"data1\": \"data goes here\", \"data2\": \"data2 goes here\"}' http: //localhost/path/to/api
所以我放棄。 的Windows似乎與POST發送的JSON對象搞亂
請不要在問題標題中加上[[解析]]。如果你已經想出了你的問題的答案,你應該把它作爲答案。 – 2012-08-06 23:20:01
感謝@CodyGray的警告。我會糾正我的帖子。 – Lothre1 2012-08-06 23:35:22
如果你的機器上安裝了git,你可以使用git bash來捲曲。它可以節省很多頭痛。 – 2017-06-28 21:03:31