0
0

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 3 years have passed since last update.

curlの代わりにHTTPieを使う

0
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?