LoginSignup
11
6

More than 5 years have passed since last update.

curl 基本コマンド (GET/POST/PUT/DELETE)

Last updated at Posted at 2019-04-03

API確認としてcurlを使う様になったのでまとめ

GET

GETはcurlコマンドの後にURLでOK

$ curl http://www.example.com/

POST/PUT/DELETE

他のメソッドは -X オプションの後にメソッド名を書けばOK

$ curl -X POST http://www.example.com/
$ curl -X PUT http://www.example.com/
$ curl -X DELETE http://www.example.com/

POSTでデータを送信

POSTでデータを送信するには-dオプションの後に書けばOK
ファイルデータの場合にはファイル名の前に@を付けるだけ

$ curl -X POST -d "hoge=0&fuga=1" http://www.example.com/
$ curl -X POST -d @hoge.json http://www.example.com/
11
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
6