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).

  • 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? – zagrimsan Nov 27 '13 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. – Patrick Nov 28 '13 at 1:32

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
  • Congrats for solving that (despite the doubts that I presented), and thanks for posting the solution. – zagrimsan Nov 28 '13 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.