... w/o escaping and another magic
Is it really?
Under option like --raw-payload
Yes, any data passed in via STDIN
will be sent as the request body, e.g.:
$ echo 'raw payload' | http httpbin.org/post
Thank you, Jakub!
Other than --ignore-stdin
I don鈥檛 see any mention of this inside http --help
, might it be a good addition to the help text? (Also, awesome job on this!)
You can also use http httpbin.org/post <<< 'raw payload'
But,
$ echo 'running' | http -v put localhost:5000/state
is sending Content-Type: application/json
header.
PUT /state HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 8
Content-Type: application/json
Host: localhost:5000
User-Agent: HTTPie/0.9.9
running
and a proper implementation on the receiving end is of course trying to parse that as a JSON, and failing.
@furkanmustafa application/json
is default content-type used by httpie
.
If you explicitly state the content type in your request, it will be resolved:
$ echo 'running' |http httpbin.org/post Content-Type:text/plain
or even with sending compressed content:
$ echo 'running' |gzip |http httpbin.org/post Content-Type:text/plain Content-Encoding:gzip
You can also use
http httpbin.org/post <<< 'raw payload'
seemed not working with powershell, 'rawBody' | http post :8080/api/events
worked for me
Most helpful comment
Yes, any data passed in via
STDIN
will be sent as the request body, e.g.:https://github.com/jakubroztocil/httpie#redirected-input