httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
33.37k stars 3.67k forks source link

Using HTTPIE with GNU Parallel #359

Closed CMCDragonkai closed 9 years ago

CMCDragonkai commented 9 years ago

This works:

seq 1 | parallel -n0 "curl -H 'Content-Type: application/json' http://httpbin.org/post -X POST -d '{\"url\":\"http://google.com/\"}'"

But this doesn't:

seq 1 | parallel -n0 "http POST http://httpbin.org/post url=http://google.com/"

The result is:

http: error: Request body (from stdin or a file) and request data (key=value) cannot be mixed.

It seems that by using a pipe with parallel, httpie is thinking that it's meant to take data from stdin/file, and won't take in the command like request data.

The -n0 command makes parallel not pass any parameters to the command.

jkbrzt commented 9 years ago

You can use --ignore-stdin to tell HTTPie to not read from standard input even though it's redirected:

$ seq 1 | parallel -n0 "http --ignore-stdin httpbin.org/post url=http://google.com/"

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