Drake Guan
Drake Guan

Reputation: 15122

How to make a post with a from data of empty json through HTTPie?

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/

Upvotes: 21

Views: 8541

Answers (3)

Hari Krishna
Hari Krishna

Reputation: 3558

Use <<< operator like below.

http POST ooxx.asdf/ Content-Type:application/json <<< '{}'

Upvotes: 7

Jakub Roztocil
Jakub Roztocil

Reputation: 16232

Verbatim request data can be specified via redirected STDIN:

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

Note that for requests that include a body:

Upvotes: 30

Sabuj Hassan
Sabuj Hassan

Reputation: 39375

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.

Upvotes: 4

Related Questions