Search code examples
javaspring-bootresttemplategsm

How to GSM Encode using RestTemplate


I am having trouble with encoding the '#' character for a SMS based product. The SMS is sent using a GET request to the API provided by the SMS Gateway provider. I am required to send a simple message "Dial #121#", but the SMS received on the Phone does not show the '#' character.

The application is built on Spring Boot and I am using the RestTemplate to make the request

RestTemplate restTemplate = new RestTemplate();
String message = "Dial #121#"; //example message
String baseUri = "http://api.example.com?msisdn=1234567&message=" + message;
ResponseEntity<String> response = restTemplate.getForEntity(baseUri, String.class);

Output on Phone : Dial

Expected Output : Dial #121#

Please Assist.


Solution

  • Issue was resolved by using the org.apache.httpcomponents:httpclient http clinet instead of Sprint Rest Template