To send a request with custom query parameters using cURL, you can append the query parameters to the URL by using the -G
or --get
flag followed by the --data-urlencode
flag.
Here is an example command:
curl -G -d "param1=value1" -d "param2=value2" "https://example.com/api/endpoint"
In this example, the -G
flag specifies GET request and -d
flag specifies the query parameters. You can include multiple -d
flags to add multiple query parameters. Finally, the URL is provided where the request should be sent.
Note: If you are using Windows Command Prompt, you may need to use double quotes instead of single quotes.
If you prefer, you can also specify the query parameters directly in the URL like this:
curl "https://example.com/api/endpoint?param1=value1¶m2=value2"
Both commands will send a GET request with the specified query parameters.