1

I tried below to pass a parameters to httpie and it turned into POST method unexpectedly.

1)
$ echo "a1 b1" | xargs -t -n2 bash -c 'http -v https://httpbin.org/anything arg1==$0 arg2==$1'
bash -c http -v https://httpbin.org/anything arg1==$0 arg2==$1 a1 b1 
2)
$ echo "arg1==a1 arg2==b1" | xargs -t -n2 bash -c 'http -v https://httpbin.org/anything'
bash -c http -v https://httpbin.org/anything arg1==a1 arg2==b1

The 1st one returns below and seem like there're additional "a1 b1" inhibit proper request.

bash -c http -v https://httpbin.org/anything arg1==$0 arg2==$1 a1 b1

The 2nd one returns seemingly not too far but actual method turned into the POST.

Is there any way to pass multiple parameters to httpie?

Yusuwa
  • 21
  • 3

2 Answers2

1

Here is a way to accomplish your goal:

echo "a1 b1" |
  awk '{print "http -v https://httpbin.org/anything arg1=="$1" arg2=="$2}' |
  bash
webb
  • 4,180
  • 1
  • 17
  • 26
1

Even if manually insert the strings like:

$ echo 'http -v https://httpbin.org/anything arg1==a1 arg2==b2' | bash

doesn't work same as below:

$ http -v https://httpbin.org/anything arg1==a1 arg2==b2

I don't get the cause of this happening but simply if I specify the method, It worked.

$ echo "a1 b1" | xargs -t -n2 bash -c 'http -v GET https://httpbin.org/anything arg1==$0 arg2==$1
                                               ^^^

and I think I got the caused it's due to stdin so it can be avoid by --ignore-stdin option.

Yusuwa
  • 21
  • 3