1

I am trying to pass a url-encoded multi-line string as parameter of a GET call to an existing web-service. I think I am getting quite close to the solution with the following:

echo -e 'p_message=a\nb\nc\n' | curl -v -G --data-urlencode @- http://localhost/service > GET /service?p_message%3Da%0Ab%0Ac%0A%0A HTTP/1.1 

It seems that the only thing that is going wrong is that the '=' is getting url-encoded. I am running the latest version of curl (7.33).

2
  • 1
    Aren't you just asking curl to URL encode the data you give it by using --data-urlencode? Passing it readily URL encoded data (the way you like it) and not using the parameter would be obvious solution, right? Commented Nov 27, 2013 at 12:03
  • Sure, however that would require an extra component and dependency, but if there is not a neater solution that may be the way I will go (via perl script to url-encode). However seems I am very close to be able to do this in pure curl, still wonder if it is possible. Commented Nov 28, 2013 at 1:32

1 Answer 1

2

Got it, the following seems to work:

echo -e "a\nb\nc\n'" | curl -v -G --data-urlencode p_message@- http://localhost/service > GET /service?p_message=a%0Ab%0Ac%0A%27%0A HTTP/1.1 
1
  • Congrats for solving that (despite the doubts that I presented), and thanks for posting the solution. Commented Nov 28, 2013 at 7:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.