JAVA Code Sample
It the example below, the SIP account is listening on port 5060. When you make the call, the SIP phone on which Alice is registered will ring and the hello-play.xml file will be played.
Visit the complete documentation here.
import java.net.URL; import javax.net.ssl.HttpsURLConnection; import java.io.*; import java.util.Base64; public class JavaSampleClass { // Provide your Account Sid and Auth Token from your Console Account page public static final String ACCOUNT_SID = "my_ACCOUNT_SID"; public static final String AUTH_TOKEN = "my_AUTH_TOKEN"; public static void main(String[] args) throws Exception { String userAndPass = ACCOUNT_SID + ':' + AUTH_TOKEN; String encoded = Base64.getEncoder().encodeToString(userAndPass.getBytes()); URL url = new URL(("https://telecomsxchange.restcomm.com/restcomm/2012-04-24/Accounts/" + ACCOUNT_SID + "/Calls.json"); HttpsURLConnection conn = (HttpsURLConnection)url.openConnection(); conn.setRequestProperty("Authorization", "Basic " + encoded); conn.setRequestMethod("POST"); conn.setDoOutput(true); DataOutputStream os = new DataOutputStream(conn.getOutputStream()); // Update POST parameters accordingly os.writeBytes("From=16175551212&" + "To=sip:alice@mycompany.com&" + "Url=https://ACCOUNT_SID:AUTH_TOKEN@mycompany.com/restcomm/demos/hello-play.xml"); os.close(); // Add your business logic below; response code can be obtained from 'conn.getResponseCode()' and input stream from 'conn.getInputStream()' ... } }