Sorry, you need to enable JavaScript to visit this website.

You are here

Send SMS Failing - 500 Error "ReferenceError: \"messageText\" is not defined.

2 posts / 0 new
Last post

Nivetha's picture
by Nivetha

Send SMS Failing - 500 Error "ReferenceError: \"messageText\" is not defined.

Iam trying to send message using Message API  https://tapi.telstra.com/v2/messages/sms Api via  java program and it is getting failed when called  .

 
Here is the code snippet
 
String url = "https://tapi.telstra.com/v2/messages/sms"; 
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer "+token);
headers.add("Content-Type", "application/json");

logger.info("setting Authorization header to: Bearer " + token);

String input = "{\"to\":[\"+9xxxxxxxx46\"],\"body\":\""+ content + "\",\"from\": \"\",\"validity\": 5,\"scheduledDelivery\": 1,\"notifyURL\": \"\",\"replyRequest\": false,\"priority\": true}";
logger.info("Setting Authorization header to: input " + input);

RestTemplate restTemplate = new RestTemplate();
HttpEntity<String> requestHeaders = new HttpEntity<String>(input, headers);

logger.info("Sending SMS -----------------------------------");
restTemplate
.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
restTemplate.setErrorHandler(new CustomResponseErrorHandler());
ResponseEntity<String>  response = restTemplate.exchange(url, HttpMethod.POST,
requestHeaders, String.class);
    
 
Error what am getting when i invoke Sms
{
"status":"500",
"code":"",
"message":"ReferenceError: \"messageText\" is not defined."
}

 

DeveloperSteve's picture
by DeveloperSteve

Hi nivethamanoharan

Have you provisioned a number against the account? 

Also have you tried sending just a plain text string in replace of the content variable?

Log in or register to post comments