LoginSignup
0
0

More than 1 year has passed since last update.

curlの代わりにHTTPieを使う

Posted at

Linuxだとほぼ標準でcurlが入ってるけど、Windowsだとインストールがちょっと面倒くさい。なのでよく使うのがHTTPieです。
Pythonが入っている環境だとインストールはとっても簡単。

pip install httpie

JSONをリクエストボディに入れてPOSTする場合は下記のようにする

http POST http://xxxx/xxx foo=10 bar=20

こうするとリクエストボディは下記のように解釈される。

sample
{
    "foo": 10,
    "bar": 20
}

複雑な構造をもつJSONもファイルにしておけばもちろんPOST可能。

sample
# For Bash
$ http POST http://xxx/xxx < req.json

# For Powershell
$ Get-Content req.json | http POST http://xxx/xxx
0
0
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
0
0