Reputation: 817
I want to use curl
for a GET
request, but the url is of the form:
localhost:<port>/getter?key=This is a sentence.
, which means that the key
is an input parameter in the endpoint.
If I use POSTMAN
for the request, then the format with the spaces is absolutely fine.
I have a hard time giving the right format when I use curl
. I have tried using the percentage symbol when we have spaces, but I cannot figure it out.
Upvotes: 0
Views: 771
Reputation: 185700
Replace:
localhost:<port>/getter?key=This is a sentence
by
'http://localhost:<port>/getter?key=This%20is%20a%20sentence'
Note the %20
.
If you want a command line to do it for you :
echo "/getter?key=This is a sentence" |
perl -MURI::Escape -lne 'print uri_escape($_);'
Upvotes: 1