2
votes

I'm trying to make a call to a number using the Twilio service using a Trial Account.

I'm following the Java example here: https://www.twilio.com/docs/quickstart/java/rest/call-request

I've configured the example with my API credentials, the provided Twilio number, the destination number and the TwiML instructions url.

When I run the MakeCall class the destination number get called.

When I respond to the call I get the "trial account" message, then it asks me to press any key. When I press a key the call is dropped.

As I can see the TwiML instructions url is not called by Twilio.

I've tested also with the Test Credentials with no success.

Any idea on why the TwiML instructions url is not called?

1
//1. Check the logs at Twilio twilio.com/user/account/log/calls //2. Use a TwiML Bin so you know you're serving proper TwiML twilio.com/blog/2016/05/… - Alex Baban
The logs says "No HTTP requests were logged for this call." - Fedy2
Tried also with TwiML Bins, same behavior.. - Fedy2
It's hard to figure out without seeing your code, but I believe the "trial account" message must come from TwiML. The one that's asking you to press a key, where is that one coming from? - Alex Baban
Twilio evangelist here. Can you post your Java code? Sounds like maybe you're not passing a URL to Twilio when you call that method. - Devin Rader

1 Answers

1
votes

Using the twilio-java helper library and following code from the docs you mentioned above:

We then instantiate a new client object, set the request method to 'POST', fill in the 'From', 'To' and 'Url' parameters in an associative array, and fire off the request to Twilio!

Aside from any potential issues with your URL...did you also set the request method to POST while configuring your twilio number in the console?

import java.util.Map;
import java.util.HashMap;

import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.Account;
import com.twilio.sdk.resource.instance.Call;
import com.twilio.sdk.resource.factory.CallFactory;

public class MakeCall {

    public static final String ACCOUNT_SID = "AC123";
    public static final String AUTH_TOKEN = "456bef";

    public static void main(String[] args) throws TwilioRestException {

        TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
        Account mainAccount = client.getAccount();
        CallFactory callFactory = mainAccount.getCallFactory();
        Map<String, String> callParams = new HashMap<String, String>();
        callParams.put("To", "5105551212"); // Replace with your phone number
        callParams.put("From", "(510) 555-1212"); // Replace with a Twilio number
        callParams.put("Url", "http://demo.twilio.com/welcome/voice/"); // Configure your own URL with TwiML instructions using TwiML Bins
        // Make the call
        Call call = callFactory.create(callParams);
        // Print the call SID (a 32 digit hex like CA123..)
        System.out.println(call.getSid());
    }
}