Curl Command - Issue with Special Characters | Community
Skip to main content
toshbot
July 13, 2017
Solved

Curl Command - Issue with Special Characters

  • July 13, 2017
  • 4 replies
  • 48018 views

Hi Folks,

I am trying to perform tree activation using a Curl command. The path contains special characters (from Spanish words). So, for example, this is the command I am executing:

curl -u admin:admin -F cmd=activate -F ignoredeactivated=true -F onlymodified=true -F path=/content/geometrixx/Cómo Hacer y Recibir Llamadas Telefónicas.png http://localhost:4502/etc/replication/treeactivation.html

When I try to execute this command, the word "Cómo" gets processed as "Cómo", and "Telefónicas" as "Telefónicas". Since there is no file with the word "Cómo", or "Telefónicas", the command fails.

Is there a way to process these special characters correctly for curl commands? Thank you.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by zeeshanKhan0786

Hi toshbot,

Solution one: It is converting the Special character to an Encoding but not in UTF-8 (browser specific encoding).Can you paste this(/content/geometrixx/Cómo Hacer y Recibir Llamadas Telefónicas.png) to browser so that the url will be already in Encode Form and then use this encoded path to your Curl command.

Solution Two :  Use --data-urlencode curl - How To Use Check this Examples linux - How to Post Url in data of a curl request - Stack Overflow

Solution Three : GO through this url http - How do I POST form data with UTF-8 encoding by using curl? - Stack Overflow

This is due to handling of unicode characters in a DOS prompt, see https://stackoverflow.com/questions/388490/unicode-characters-in-windows-command-line-how . You should be able to change this behavior by using a command like chcp 65001 to set the terminal up for UTF-8 handling.

Thanks

4 replies

zeeshanKhan0786
zeeshanKhan0786Accepted solution
July 13, 2017

Hi toshbot,

Solution one: It is converting the Special character to an Encoding but not in UTF-8 (browser specific encoding).Can you paste this(/content/geometrixx/Cómo Hacer y Recibir Llamadas Telefónicas.png) to browser so that the url will be already in Encode Form and then use this encoded path to your Curl command.

Solution Two :  Use --data-urlencode curl - How To Use Check this Examples linux - How to Post Url in data of a curl request - Stack Overflow

Solution Three : GO through this url http - How do I POST form data with UTF-8 encoding by using curl? - Stack Overflow

This is due to handling of unicode characters in a DOS prompt, see https://stackoverflow.com/questions/388490/unicode-characters-in-windows-command-line-how . You should be able to change this behavior by using a command like chcp 65001 to set the terminal up for UTF-8 handling.

Thanks

toshbot
toshbotAuthor
July 13, 2017

Hi,

Thank you for your response. Couple of things:

1. Copying and then pasting my URL into a browser, the special character 'ó' still remains the same. It does not change/get encoded.

2. How would you use the encoding in our particular context aka for tree activation? I think the use cases in the first two links you posted will not work. These apply to encoding query parameters - in this case, there are no query parameters.

The path /content/geometrixx/Cómo Hacer y Recibir Llamadas Telefónicas.png does not contain any query params.

Any guidance would be appreciated.

zeeshanKhan0786
July 13, 2017

Hi

did you check that image is comming by hitting the original url http://<hostname>:<port>/content/geometrixx/Cómo Hacer y Recibir Llamadas Telefónicas.png.If image is comming then you can use this encoded url in curl command.

If you check this you can use  --data-urlencode before the path of the relative url.

curl --request POST 'http://localhost/Service' --data-urlencode "path=/xyz/pqr/test/";

toshbot
toshbotAuthor
July 13, 2017

Hi,

So in the URL, Cómo remains as it is - it isn't encoded to something special.

So, what I actually want is for curl to NOT encode my URL - I want to disable encoding.

Do you know how I can achieve that?