Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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/
like image 765
Drake Guan Avatar asked Apr 06 '14 06:04

Drake Guan


People also ask

How do you create an empty JSON in Python?

How to create a JSON file in Python. To create a json file in Python, use with open() function. The open() function takes the file name and mode as an argument. If the file is not there, then it will be created.


3 Answers

Verbatim request data can be specified via redirected STDIN:

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

Note that for requests that include a body:

  • POST is the default HTTP method
  • application/json is the default Content-Type
like image 128
Jakub Roztocil Avatar answered Sep 24 '22 19:09

Jakub Roztocil


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.

like image 43
Sabuj Hassan Avatar answered Sep 26 '22 19:09

Sabuj Hassan


Use <<< operator like below.

http POST ooxx.asdf/ Content-Type:application/json <<< '{}'
like image 36
Hari Krishna Avatar answered Sep 24 '22 19:09

Hari Krishna