I’ve written a nodejs package that allows you to make HTTP(S) requests from the Windows terminal, so you type in something like http get https://stackoverflow.com and bam, there’s the response. Something I’ve noticed, however, is that using an ampersand (&) in a URL breaks the command. It seems like this is a feature built in to let you run multiple commands in one line. So if you run:
http get https://api.example.com/getinfo?request=example&apikey=APIKEY, then it makes a request to https://api.example.com/getinfo?request=example, and then tries to run ‘apikey’ as a command, yielding the error: 'apikey' is not recognized as an internal or external command, operable program or batch file.
Is there a way I can get around this?
>Solution :
I don’t know if this works on Windows as well, but on Linux you can put a string in single or double quotes. Then the string is given to the application without being interpreted by the terminal (except for replacing environment variables with $ in double-quotes). This is also useful if you want to pass an argument with whitespaces.
So, try
http get "https://api.example.com/getinfo?request=example&apikey=APIKEY"
or
http get 'https://api.example.com/getinfo?request=example&apikey=APIKEY'