1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

curl備忘

Last updated at Posted at 2023-04-29

自分用。毎回調べているのでまとめておく

  1. GETリクエスト
curl https://api.example.com/resource
  1. POSTリクエスト
curl -X POST https://api.example.com/resource
  1. POSTリクエスト(JSONデータを送信)
curl -X POST -H "Content-Type: application/json" -d '{"key1":"value1", "key2":"value2"}' https://api.example.com/resource
  1. PUTリクエスト
curl -X PUT https://api.example.com/resource/id
  1. PUTリクエスト(JSONデータを送信)
curl -X PUT -H "Content-Type: application/json" -d '{"key1":"new_value1", "key2":"new_value2"}' https://api.example.com/resource/id
  1. DELETEリクエスト
curl -X DELETE https://api.example.com/resource/id
  1. Basic認証
curl -u username:password https://api.example.com/resource
  1. Bearerトークン認証
curl -H "Authorization: Bearer <ACCESS_TOKEN>" https://api.example.com/resource
  1. カスタムヘッダーの追加
curl -H "Custom-Header: custom_value" https://api.example.com/resource
  1. 複数のヘッダーを追加
curl -H "Content-Type: application/json" -H "Custom-Header: custom_value" https://api.example.com/resource
  1. レスポンスヘッダーの表示
curl -I https://api.example.com/resource
  1. リダイレクトを追跡
curl -L https://api.example.com/resource
  1. タイムアウトの設定
curl --max-time 10 https://api.example.com/resource
  1. jsonファイルからリクエスト
curl -X POST -H "Content-Type: application/json" -d @jsonpath https://api.example.com/resource
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?