20

I'm wondering how to make a POST request with a from data of empty json through HTTPie? The corresponding Curl solution is here:

curl -X POST -H "Content-Type: application/json" -d '{}' http://ooxx.asdf/
Drake Guan
  • 14,514
  • 15
  • 67
  • 94

3 Answers3

28

Verbatim request data can be specified via redirected STDIN:

$ echo '{}' | http httpbin.org/post

Note that for requests that include a body:

Jakub Roztocil
  • 15,930
  • 5
  • 50
  • 52
  • In windows, the single quotes in `echo '{}' | http httpbin.org/post` can omit. just `echo {} | http httpbin.org/post` – Edward Sep 13 '16 at 06:27
7

Use <<< operator like below.

http POST ooxx.asdf/ Content-Type:application/json <<< '{}'
Hari Krishna
  • 3,658
  • 1
  • 36
  • 57
4
http POST ooxx.asdf/ Content-Type:application/json '{}'

Another option using json file that contains {}:

http POST ooxx.asdf/ < file.json

More about json posting you can find from here.

Sabuj Hassan
  • 38,281
  • 14
  • 75
  • 85