Escape colon in curl with -u option

curl

I can't wrap my head around how to escape semicolon in username while making a GET request.

curl -u testclient:sdtest1:pass -XGET -H "Content-type:application/json" \
http://localhost:8081/hello

But the server says that credentials are invalid. How can I escape this?

Best Answer

How do I escape a special character in a username while making a GET request.

Find the hexidecimal value of the value to be escaped, and prefix it with %.

So in your case, use the following:

curl -u testclient%3A:sdtest1:pass ...

"Is there any way that I can specify a username containing a colon"

"user:name:password" => "user%3Aname:password"

Source Specifying colon in authentication username