zet zet - 4 months ago 14
HTTP Question

How to use http to send json

I am very new to http commands and apache bench, trying to do a simple benchmark. I had a question about how to send a json file usine httpie.

I saw an old example that used an older cli to do it like this:

http --verbose post example.org file.json --content-type="application/json"


However, I am unsure how to do this in httpie. I know that this part:

http --verbose post example.org


Would remain the same. But I don't know how I would do:

file.json --content-type="application/json


in httpie

Answer

This is the simplest HTTPie command for sending a JSON file:

$ http example.org @file.json

https://github.com/jkbrzt/httpie#request-data-from-a-filename