3

I am integrating Plivo SMS API with my java web application. I want to send messages through my application. I am referring to https://www.plivo.com/docs/getting-started/send-a-single-sms/ link. Below is the code snippet:

String authId = "{my Auth_id}"; //Your Authentication ID
String authToken = "{my auth Token}"; //Your authentication code
RestAPI api = new RestAPI(authId, authToken, "v1");

LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
parameters.put("src", "+44*******"); // Sender's phone number with country code
parameters.put("dst", "+91*******"); // Receiver's phone number with country code
parameters.put("text", "Hi, text from Plivo"); // Your SMS text message

try {
  // Send the message
  MessageResponse msgResponse = api.sendMessage(parameters);
  // Print the response
  System.out.println(msgResponse);
  // Print the Api ID
  System.out.println("Api ID : " + msgResponse.apiId);
  // Print the Response Message
  System.out.println("Message : " + msgResponse.message);

  if (msgResponse.serverCode == 202) {
  // Print the Message UUID
  System.out.println("Message UUID : " +   msgResponse.messageUuids.get(0).toString());
  } else {
     System.out.println(msgResponse.error);
         }
        } catch (PlivoException e) {
            System.out.println(e.getLocalizedMessage());
     }

I tried to run this code using console application as well as web application.I am getting exception "com.plivo.helper.exception.PlivoException: Connection to https://api.plivo.com refused". What is wrong with my code? Am I missing anything here?

Manushi
  • 33
  • 4
  • Please check your firewall settings to ensure that it's not blocking any traffic. Also, are you using a web proxy? If yes, make sure that your application is using this proxy to handle connections. – Ramya Raghu Jan 16 '17 at 12:49
  • Yes,there was a problem of proxy settings and somehow that was blocking the connection to API. I changed my proxy settings and it started working. Thank you for your help! – Manushi Jan 17 '17 at 04:48
  • Great! Please mark the questions as answered. – Ramya Raghu Jan 17 '17 at 09:27

1 Answers1

1

Plivo Sales Engineer here.

Please check your firewall settings to ensure that it's not blocking any traffic. Also, are you using a web proxy? If yes, make sure that your application is using this proxy to handle connections.

Ramya Raghu
  • 409
  • 3
  • 4