I have a problem that I just cannot seem to solve.
I need to make a curl request to a given URL, and the URL requires a dollar sign in it.
So, for example:
www.example.com/mypath/function&$filter=whatever
Now, I can execute this just fine from the command line if I put the URl in single ticks, or if I escape the dollar sign with a backslash, and then put it in a double quote.
Obviously, there is a problem if you do not do either of the above, because bash will see the '$' and will interpret anything after it to mean a variable name.
So when I try:
URL="www.example.com/mypath/function&\\\$filter=whatever"
MYOUTPUT=$(curl -s --header "Authorization: $HEADER" "$URL")
it doesn't work right.
When I try
URL="www.example.com/mypath/function&\$filter=whatever"
MYOUTPUT=$(curl -s --header "Authorization: $HEADER" "'$URL'")
it doesn't work right.
What am I doing wrong?
I can tell it's not working right because the server is not responding the same way in the script as it does in the command line. The site responds in a certain default manner if the query isn't done right, and I always get the default response through the script.
No comments:
Post a Comment