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/
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.
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
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.
Use <<< operator like below.
http POST ooxx.asdf/ Content-Type:application/json <<< '{}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With