16
13

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

httpie: POSTリクエストのBodyをファイルで定義したい

Posted at

httpieでPOSTリクエストのBodyをファイルから提供する方法。リダイレクトで標準入力に与えるだけ。

$ http -v POST localhost:8888/bbs/ < data.json

ファイルの中身

data.json
{
  "id": "123456",
  "title": "Hello",
  "content": "Hello World!"
}

httpieから送られるPOSTリクエスト

POST /bbs/ HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Content-Length: 70
Content-Type: application/json; charset=utf-8
Host: localhost:8888
User-Agent: HTTPie/0.8.0

{
    "content": "Hello World!",
    "id": "123456",
    "title": "Hello"
}
16
13
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
16
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?