curl -I 這樣其實發送是HEAD請求。
下面這樣發送POST請求(-X POST),同時指定Basic認證用戶名密碼(-u ‘andy:andy’),同時指定數據類型(-H ‘Content-Type: application/json’),以及發送的數據(–data ‘xxxx’)。同時將response的Header打印到控制台(-D -)。
curl 'http://127.0.0.1/test' -X POST -u 'andy:andy' -H 'Content-Type: application/json' --data '{"username":"test", "password": "test"}' -D -
curl -D 表示
-D, --dump-header FILE Write the received headers to FILE
下面命令中最后一個橫線表示把當前終端當作文件輸出。
curl -D -
參考原文:https://blog.csdn.net/hxg117/article/details/88351158 作者:Andy__Han
-----------------------------------------------------------------------------------------------------------
curl -X POST 'Content-Type: application/json' --header 'Accept: */*' 'http://127.0.0.1:8080/jweb/user/apilogin?username=wenbin.ouyang@amberaigroup.com&password=xxx'