resttemplate not send body unicode chars
See original GitHub issueAffects: Spring Boot 2.1.13
i have tryed to send same body with: curl, postman and rest template with java.
with rest template chars not show correctly
private CompletableFuture<String> sendToFCM(String entity, String firebaseServerKey) {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("Authorization", "key=" + firebaseServerKey);
HttpEntity<String> request = new HttpEntity<>(entity, headers);
restTemplate.getMessageConverters().add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
String firebaseResponse = restTemplate.postForObject(FIREBASE_API_URL, request, String.class);
return CompletableFuture.completedFuture(firebaseResponse);
}
I attach
curl -X POST --header “Authorization: key=KEY IS HIDDEN” --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”}}’
curl or postman result is right
Can you help me?
Best Regards
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Java Spring resttemplate character encoding - Stack Overflow
I have solved this problem. I need to POST a string object in request body with UTF-8.
Read more >Using URL encoding to handle special characters in a ...
In this article, we will walk through a scenario where exceptions are thrown if such a URI with special character is not handled...
Read more >REST API Unicode characters not working
I've been able to reproduce this in a test environment using Workbench. It appears that Salesforce by default interprets text in the body...
Read more >Uploading a file with a filename with Spring RestTemplate
File upload is sent via Multipart Form Data. This format allows to embed multiple independent information in the body of an HTTP Post...
Read more >Spring Boot REST Template URI Encoding - DZone
If using special characters, you might want to use the URL encoder on specific charsets. In this case, we're using UTF_8. This is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
@encircled in this mode? RestTemplate restTemplate = new RestTemplate();