Httpie: Is possible send raw post payload

Created on 14 May 2015  ·  7Comments  ·  Source: httpie/httpie

... w/o escaping and another magic

Is it really?

Under option like --raw-payload

question

Most helpful comment

Yes, any data passed in via STDIN will be sent as the request body, e.g.:

$ echo 'raw payload' | http httpbin.org/post

https://github.com/jakubroztocil/httpie#redirected-input

All 7 comments

Yes, any data passed in via STDIN will be sent as the request body, e.g.:

$ echo 'raw payload' | http httpbin.org/post

https://github.com/jakubroztocil/httpie#redirected-input

Thank you, Jakub!

Other than --ignore-stdin I don’t 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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sensibleish picture sensibleish  ·  3Comments

poskadesign picture poskadesign  ·  7Comments

loretoparisi picture loretoparisi  ·  6Comments

rashthedude picture rashthedude  ·  3Comments

hrj picture hrj  ·  5Comments