curl 测试接口


curl 测试接口

curl 参考链接

https://curl.haxx.se/docs/manpage.html

https://curl.haxx.se/docs/manual.html

-X POST; 定义请求方法为POST

-H "Content-Type:application/json"; 定义请求头

-F "file=@/path/to/file"; 'POST' 'multipart/form-data ' 提交

-d "hello=world"; 提交的数据

GET

curl -d "hello=world" -d "test=curl" http://localhost/test/get

// http://localhost/test/get?hello=world&test=curl

POST

  • 提交表单
curl -X POST -F "hello=world" -F "file=@/path/to/file.jpg" http://localhost/test/post/form

// 提交输入内容和文件
  • 提交json
curl -X POST -H "Content-Type:application/json" -d '{"hello": "world", "test": "curl"}' http://localhost/test/post/json

PUT

curl -X PUT -H "Content-Type:application/json" -d '{"hello": "world", "test": "curl"}' http://localhost/test/put

DELETE

curl -X DELETE -H "Content-Type:application/json" -d '{"hello": "world", "test": "curl"}' http://localhost/test/delete


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM