Leonard Saers opened SPR-11572 and commented

Thanks for a great work, and a grate framework.

It would be nice if it also was possible to specifying which URL encoding to use.

Eg. The following call will now encode in Unicode. ø will be encoded as %F8 templateResult = template.postForObject(uri, parameters, DOMSource.class);

Suggestion, make it possible to specify encoding:

Eg. The follwing call should then encode in UTF-8. ø will be encoded as %C3%B8 templateResult = template.postForObject(uri, parameters, DOMSource.class,"UTF-8");

To encode as UTF-8, The only solution now is to build and encode the URL as UTF-8. Then use:

templateResult = template.getForObject(uri, DOMSource.class);

But this approach will not allow one to send UTF-8 encoded post data.


Reference URL: http://forum.springsource.org/showthread.php?110703-Change-RestTemplate-URL-encoding

Comment From: spring-projects-issues

Leonard Saers commented

It is possible to send the get data in UTF-8 and at the same time send post data.

By using, the following method: \ DOMSource org.springframework.web.client.RestTemplate.postForObject(URI url, Object request, Class\ responseType) throws RestClientException

You could enter parameters in the url and encode the url as you like, eg. UTF-8, but the post data, defined in the Object request parameter will be encoded as Unicode.

That is, it is possible to send smaller amount of data encoded as UTF-8. The data sent by post can often be much larger in size, so if you need to send a large amount of data, you need to send it as post and then it will be encoded as Unicode by the Spring Web Service

This feature request may still be relevant, but there are probably other ways in spring which should be used to solve this, so maybe it's time to close this issue.

Comment From: spring-projects-issues

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Comment From: sante85

curl -X POST --header "Authorization: key=KEYYYY" --Header "Content-Type: application/json;charset=ISO-8859-1" https://fcm.googleapis.com/fcm/send -d '{"to":"/topics/VgtARwhilq","notification":{"body":"\uD83D\uDD25","content_available":true,"priority":"high","title":"\uD83D\uDD25"},"data":{"click_action":"FLUTTER_NOTIFICATION_CLICK","body":"\uD83D\uDD25","title":"\uD83D\uDD25","content_available":true,"priority":"high"}}'

vs rest template not send \uD83D\uDD25 char correctely

Comment From: sante85

i have a true example

Comment From: sante85

i we want i send server key to test

Comment From: sante85

call with curl

Comment From: sante85

with rest template send unicode char, not emojj