我想以更易于閱讀的方式格式化有效的 GET 請求。有很多引數,將來可能會更多。因此,如果是檔案,您將如何在 cURL 命令中格式化長 URL?最好queryparam在換行符中顯示每個。
curl --header 'header1: XXXXXX' 'https://localhost/api/similar?word=science&target=en&target=fr&target=bg&target=ar&target=fr&source=en&limit=10&score=0.5'
請注意target有效的重復引數(并且根據服務器端的查詢決議器被解釋為陣列)。
編輯:這是我已經嘗試過但沒有成功的方法:
curl -XGET -G 'https://localhost/api/similar?' \
-d word=science \
-d target=en \
-d target=fr \
-d target=bg \
-d target=ar \
-d target=fr \
-d source=en \
-d limit=10 \
-d score=0.5
不幸的是,這不起作用
uj5u.com熱心網友回復:
你非常接近:) 只需將 -XGET 替換為 --get 就可以了
curl --get 'https://localhost/api/similar?' \
-d word=science \
-d target=en \
-d target=fr \
-d target=bg
另請注意,多行 shell 呼叫的 \ 語法特定于 posix shell,這意味著它在 Microsoft Windows 上不起作用,在 Windows 的 cmd 中它將是
curl --get 'https://localhost/api/similar?' ^
-d word=science ^
-d target=en ^
-d target=fr ^
-d target=bg
(同樣 ^ 是 Windows 獨有的,因此不能在 posix shell 上作業~)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/505191.html
