How to use Curl to send parameters and values?

Viewed 6396

i am trying to send a curl request to a webpage using GET to send parameters with their values. it works for the first two, but the last one "a-listibg-pro" keeps giving me trouble because of the hyphen i assume. please help

 curl -X GET <url>?"type"="fruit"&"number"="two hundred and one"&"a-listing-pro"="yes but conditional"
1 Answers

Hypens are URL safe, so that should not be the problem.

Mind, that spaces and other special chars need to be URL encoded before used in a query string.

https://www.w3schools.com/tags/ref_urlencode.ASP

Spaces are usually encoded with %20 or +, so your string can be used as

curl "https://example.com/?type=fruit&number=two%20hundred%20and%20one&a-listing-pro=yes%20but%20conditional"

(curl defaults to GET so no need for -x)

Related