2015-04-01 86 views
0

我正在使用Flask編寫API。用瀏覽器測試的偉大工程:使用Curl測試API

http://stuff.com/[email protected]&password=testpassword

回報我的期望。

不過,我想打字成捲曲兩種方式(原諒無知,新LAMP)

捲曲http://stuff.com/[email protected]&password=testpassword

捲曲-i http://stuff.com/[email protected]&password=testpassword

不幸的是,在查詢中的變量AREN」因爲我的錯誤信息類似於傳遞:

http://stuff.com/login?username=

幫助?

+0

,我不知道,但就是這個幫扶: http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a -post-request ? – caiuspb 2015-04-01 14:31:39

+1

嘗試用單引號括起URL:'curl'http://stuff.com/login?username = test @ test.com&password = testpassword'' – lsowen 2015-04-01 14:33:48

+0

明白了。謝謝。隨時回答,我會覈實。 – 2015-04-01 14:41:26

回答

1

我相信是因爲你的shell正在評估你正在使用的參數GET,而不是將它們作爲字符串傳遞。爲防止出現這種情況,請在請求url周圍使用單引號。例如:

curl 'http://stuff.com/[email protected]&password=testpassword'