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