LoginSignup
52
39

More than 5 years have passed since last update.

curlコマンドでデータを送るときに、ファイルに保存されたデータを使う

Posted at

概要

curlコマンドでHTTPリクエストのボディにデータを入れるときに、コマンドラインで指定するだけでなく、ファイルから読み込んだデータを使うことができる。

やり方

データを送る一般的なやり方。

$ curl -d "{ \"key\": \"value\"}" -H "Content-Type: application/json" http://example.com

ファイルから読み込む。

$ curl -d @your_file.json -H "Content-Type: application/json" http://example.com

標準入力から読み込むこともできる。

$ curl -d @- -H "Content-Type: application/json" http://example.com
52
39
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
52
39