Curl の http クライアントの使い方 (Post)


curl で POST を行う方法です。
実行結果は同じです。

1) パラメーター名と値を与える。

curl -X POST https://httpbin.org/post -d 'user=jiro' -d 'password=123456'

2)JSON 形式で値を与える。

curl -X POST -H "Content-Type: application/json" \
    -d '{"user":"jiro","password":"123456"}' \
    https://httpbin.org/post

3)JSONファイルを使う。

curl -X POST -H "Content-Type: application/json" \
    -d@in01.json \
    https://httpbin.org/post
in01.json
{"user":"jiro","password":"123456"}