0

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.

1 Answer 1

1

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($_);'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.