Using CURL command with special characters in URL

Hi.
I 'm trying to hit a REST api and retrieve a JSON feed, and the URL has special characters in it.
Something like:
Example Domain

The below curl command is failing

curl -X GET https://www.example.com/?sample=name&id=1001

saying bad command at id=1001

I am going to use this as part of my script which will accept the url as parameter.

Can i use any option of the curl command to encode the & characters in the url automatically?

Please help.

Thank you.
Kumarjit

Try escaping the & character to prevent the shell from sending the curl command to background.

For sheer curiosity - which special character do you see?

Instead of looking for characters that are special to the shell and individually escaping them, it might be simpler to just quote the argument you're passing to curl :

curl -X GET "https://www.example.com/?sample=name&id=1001"

Thanks all. The command worked with enclosing the URL with double quotes and it worked.

Regards
Kumarjit