question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add option to ignore stdin data

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

This error is rather cryptic. I’m writing a shell script to interact with a rest API, and I’m doing this:

http --output subnet --pretty format --form post "${URLHOST}subnets" "cidr=${cidr}" "name=${name}" "description=${name}" "availabilityZoneId=${az}" "networkId=${VPCid}" "$ACCESSKEY" "$SECRETKEY" "$ACCOUNTID" "_providerId=aws" "_regionId=${REGION}"

Which produces (when preceded by ‘echo’ a command that works perfectly well. However, this version gives the error in the subject.

Am I being stupid, or is this something else?

FYI: The result of the above is as followed (sanitized slightly)

http --output subnet --pretty format --form post https://test.grid.domain.com/subnets cidr=10.124.33.128/25 name=Load_balancers description=Load_balancers availabilityZoneId=us-east-1c networkId=vpc-31433e7e x-gridauth-accesskey:DOYOUNEEDTOKNOW x-gridauth-secretaccesskey:WHATISWITHALLTHEQUESTIONS x-gridauth-accountid:11223344556677 _providerId=aws _regionId=us-east-1

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:5
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

34reactions
sgollcommented, May 26, 2020

For future reference, there now is a CLI argument --ignore-stdin that can be used to explicitly tell HTTPie that request data (key=value) should be preferred over request body (from stdin).

http --ignore-stdin http://… lorem=ipsum dolor=sit

Cf. https://httpie.org/docs#redirected-input

12reactions
jakubroztocilcommented, Jul 23, 2013

I see, the problem is that in the loop context HTTPie inherits its STDIN (which is redirected).

You should be able to work it around by changing HTTPie’s STDIN back to the terminal input (< /dev/tty):

cat file | while read line; do 
    http POST example.org  a="$line" < /dev/tty
done
Read more comments on GitHub >

github_iconTop Results From Across the Web

Add option to ignore stdin data · Issue #150 · httpie ... - GitHub
http: error: Request body (from stdin or a file) and request data (key=value) cannot be mixed. This error is rather cryptic. I'm writing...
Read more >
How do I ignore stdin with `xargs`? [duplicate] - Stack Overflow
I'm using xargs + seq to run a command several thousand times in parrallel. However xargs is appending the output of stdin to...
Read more >
How to signal the end of stdin input - Unix Stack Exchange
The simple, non-technical, answer is that Ctrl + D terminates the STDIN file and that Ctrl + C terminates the active application. Both...
Read more >
Full Listing of Options and Their Descriptions - Flake8
The difference to the --ignore option is, that this option can be used to selectively add individual codes without overriding the default list...
Read more >
borg create — Borg - Deduplicating Archiver 1.2.2 ...
Reading from stdin yields just a stream of data without file metadata associated with it, and the files cache is not needed at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found