2013-08-22 29 views
3

我在做一個安靜的api調用,但是出現錯誤。cURL - 在給定範圍內發現無效字符'開始' - '停止'

Warning: Invalid character is found in given range. A specified range MUST 
Warning: have only digits in 'start'-'stop'. The server's response to this 
Warning: request is uncertain. 
HTTP/1.1 200 OK 
Date: Thu, 22 Aug 2013 17:43:19 GMT 
Server: Apache 
Content-Length: 208 
Allow: GET, HEAD, POST 
Vary: Authorization 
Content-Type: application/json 

有沒有人看到過有關無效字符之前的WARNING錯誤?我如何解決它?

我打電話:

curl https://my/url/for/api --include -H "Content-Type:application/json" -request POST '{ \"type\": \"code\", \"objects\" : [ \"123456\" ] } ' -u user:pass 

更多信息:

在捲曲無法瞭解該方括號在命令返回

curl: (6) Could not resolve host: POST; nodename nor servname provided, or not known 

curl: (3) [globbing] nested braces not supported at pos 33 

回答

1

我也有類似的情況 - 我curl要求基本上工作,並返回我需要的信息,但警告,使用下面的代碼:

curl -request http://... 

原來是-request參數,我錯誤地鍵入。它要麼必須是這樣的:

curl --request GET http://... 
在所有

或根本不存在(因爲GET是默認):

curl http://... 
1

年底額外的響應。它將它們解釋爲它應該處理的一系列字符。無論哪種方式您的問題可能適合SuperUser比在Stackoverflow更好。

1

一個糾正命令行可能看起來像:

curl https://my/url/for/api \ 
--include \ 
-H "Content-Type:application/json" \ 
-d '{ \"type\": \"code\", \"objects\" : [ \"123456\" ] } ' \ 
-u user:pass 

我做的改變(我把它拆分爲多行以提高可讀性。):

1 - --request需要兩個破折號,但由於你設置POST,這是多餘的,我刪除它

2 - 使用-d(或--data)指定要發佈的內容。 --request只需要一個方法字符串 ,你可以用代替 POST在HTTP請求中,但我不認爲你想要那樣。

相關問題