Oleg Shirokikh
Oleg Shirokikh

Reputation: 3575

Pass parameter string in URL similar to -d CURL command

Very basic question about curl:

I can successfully pass a string parameter to the application exposing REST API on localhost with:

curl -d "stringParam = a b c d" 'localhost:8080/jobs?appName=testApp'

How would I compose regular URL that can be entered in a browser? I've tried:

localhost:8080/jobs?appName=testApp&stringParam="a b c d"

, but it doesn't work.

Upvotes: 1

Views: 1714

Answers (1)

Paul Samsotha
Paul Samsotha

Reputation: 209102

With cURL, when you use the -d switch, it will automatically turn it in to a POST request with the data (-d) as the entity body. What you are trying to do with the browser is send it in the URL (via implicit GET), which is not the same. In the the URL, it is a query parameter. What you are doing in the browser is the same as if you were to send the cURL request to that same URL (as you are with the Browser), without the -d switch. That will send a default GET, just like the browser.

If you want to do browser work, I'd suggest installing a browser extenstion, like Postman for Chrome or Rest Client for Firefox, or Advanced Rest Client for Chrome. There you can POST data to your REST services.

Upvotes: 2

Related Questions