有時候我們需要在linux服務器通過curl 調用接口,當多個參數時,如果參數拼接在url上,&後面的參數會被忽略。
比如:
curl http:localhost:8080/aaa?a=111&b=222&c=333
等效於
curl http:localhost:8080/aaa?a=111
網上有說,&前加個轉義符“\”,
curl http:localhost:8080/aaa?a=111\&b=222\&c=333
但是會報錯,也許是curl版本問題吧。
於是通過找資料整理,找到如下正確的方式:
curl -X GET -G --data-urlencode "a=111" --data-urlencode "b=222" --data-urlencode "c=333" -i http:localhost:8080/aaa