Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Curl Command - Issue with Special Characters

toshbot
Level 2
Level 2

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.

desktop_exl_promo_600x100_weknowyou.png

1 Accepted Solution
zeeshanKhan0786
Correct answer by
Level 5
Level 5

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

View solution in original post

4 Replies
zeeshanKhan0786
Correct answer by
Level 5
Level 5

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
Level 2
Level 2

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
Level 5
Level 5

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
Level 2
Level 2

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?