curl 模拟GET与POST请求,以及上传文件

curl GET 请求

curl http://localhost:8080/api/user/list

curl http://localhost:8080/api/user/list -v

-v表示查看详细的请求信息

curl POST 请求

可以使用-X POST申明请求方法,-d传送参数

curl http://localhost:8080/api/article -X POST -d "title=title&homepage=AppBlog.CN"

这是一个普通的post请求,一般我们的接口都是json格式的,可以用-H参数申明请求的header

curl http://localhost:8080/api/article -X POST -H "Content-Type:application/json" -d '{"title":"title","homepage":"AppBlog.CN"}'
curl http://localhost:8080/email/send/async -X POST -H "Content-Type:application/json" -d '{"to":"test@iobeta.com","subject":"test","content":"content"}'

我们可以利用-H来设置更多的header,比如用户的token之类的

curl http://localhost:8080/api/article -X POST -H "Content-Type:application/json" -H "Authorization:Bearer xxx" -d '{"amount":"10.8"}'

curl POST 上传文件

curl指定参数-F "file=@__FILE_PATH__"即可传输文件:

curl http://localhost:8000/api/upimg -F "file=@/home/yezhou/test.png" -H "token: xxx" -v
上一篇 VirtualBox采坑记录
下一篇 无需绑定设备,下载Google Play上的某个apk文件
目录
文章列表
1 获取Spring Cloud Gateway响应参数,可以查看、修改
获取Spring Cloud Gateway响应参数,可以查看、修改
2
Android 5.0以下Glide加载https图片问题
Android 5.0以下Glide加载https图片问题
3
Shell使用Jenkins的boolean值
Shell使用Jenkins的boolean值
4
TestNG执行流程
TestNG执行流程
5
如何在 ConstraintLayout 中设置负值的 Margin
如何在 ConstraintLayout 中设置负值的 Margin
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。