如果http地址中包含英文叹号(!),应加反斜线转义(\!)
目录
curl GET请求
curl GET请求不带参数
格式:
curl -X GET http地址
示例:
curl -X GET http://127.0.0.1:8080/update-comp
curl GET请求带params参数
格式:
curl -X GET http地址?key1=value1&key2=value2
示例:
curl -X GET http://127.0.0.1:8080/update-comp?t=ftws&sid=123
curl GET请求带x-www-form-urlencoded参数
格式:
curl -X GET -H 'Content-Type: application/x-www-form-urlencoded' -d 'key1=value1&key2=value2' http地址
示例:
curl -X GET -H 'Content-Type: application/x-www-form-urlencoded' -d 't=ftws&sid=123' http://127.0.0.1:8080/update-comp
curl GET请求带form-data参数
格式:
curl -X GET -H 'content-type: multipart/form-data;' -F 'key1=value1' -F 'key2=value2' http地址
示例:
curl -X GET -H 'content-type: multipart/form-data;' -F 't=ftws' -F 'sid=123' http://127.0.0.1:8080/update-comp
curl GET请求带header参数
格式:
curl -X GET -H 'key1: value1' -H 'key2: value2' http地址
示例:
curl -X GET -H 'cache-control: no-cache' -H 'sid: 234' http://127.0.0.1:8080/update-comp
curl POST请求
curl POST请求不带参数
格式:
curl -X POST http地址
示例:
curl -X POST http://127.0.0.1:8080/update-comp
curl POST请求带json参数
json数据要放在单引号里面
格式:
curl -X POST -H "Content-Type:application/json" -d 'json数据' http地址
示例:
curl -X POST -H "Content-Type:application/json" -d '{"fileNames":["20210626","20210627","20210628","20210629"]}' http://127.0.0.1:8080/delete-file
curl POST请求带x-www-form-urlencoded参数
json数据要放在单引号里面
格式:
curl -X POST -H "Content-Type:application/x-www-form-urlencoded" -d 'key1=value1&key2=value2' http地址
示例:
curl -X POST -H "Content-Type:application/x-www-form-urlencoded" -d 'token=123&id=3456' http://127.0.0.1:8080/update
curl POST请求带form-data参数
key3的值为文件路径
格式:
curl -X POST -H 'content-type: multipart/form-data;' -F 'key1=value1' -F 'key2=value2' -F='key3=@文件路径' http地址
示例:
curl -X POST-H 'content-type: multipart/form-data;' -F 't=ftws' -F 'sid=123' -F 'key3=@D:\ceshi\dlaqfgwlb2.pdf' http://127.0.0.1:8080/update-comp
curl POST请求带header参数
格式:
curl -X POST -H 'key1: value1' -H 'key2: value2' http地址
示例:
curl -X POST -H 'cache-control: no-cache' -H 'sid: 234' http://127.0.0.1:8080/update-comp