Test Case
The request, as stands, to https://api.ip2country.info/ip?5.6.7.8
by httpie return a redirect error code, yet works in postman api.ip2country.info/ip?5.6.7.8
.
Solution
The request works in postman because postman directly accesses the url with hard-coded query params. Httpie is supposed to be "easier" by allowing a builder interfact on the command line.
The command http api.ip2country.info ip==5.6.7.8
will essentially build a request to http://api.ip2country.info?ip=5.6.7.8
which is different then the intended url plugged into postman.
- Intended:
https://api.ip2country.info/ip?5.6.7.8
- Actual:
http://api.ip2country.info?ip=5.6.7.8
By directly coding the query params into httpie and changing the scheme to https like https api.ip2country.info/ip?5.6.7.1
, a response of
{
"countryCode": "DE",
"countryCode3": "DEU",
"countryEmoji": "" ,
"countryName": "Germany"
}
is retrieved. The only provided query param is a single key IP with no value, which httpie doesn't support in their builder (since it's fairly taboo), and requires it to just be manually appended to the end of the request URL with ?{ip}