Linux中curl发送get、post请求

时间秒杀一切 提交于 2020-03-04 16:23:50

一、get请求
curl 加地址

curl http://192.168.1.2:8080/server/test/query?id=1

二、post请求
1)无参请求

curl -d "" http://192.168.1.2:8080/server/test/deleteAll

2)带有参数
①参数使用&拼接:

curl -d "id=1&name=user"  http://192.168.1.2:8080/server/test/deleteById

②参数直接放在Header里:

curl -H "Content-Type:application/json" -X POST -d '{"id": "1", "name":"user"}' http://192.168.1.2:8080/server/test/deleteByIds
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!