Lasan
Lasan

Reputation: 183

Twilio sms sending giving errors , using java

I am try to send sms from my phone number to my phone number . it gives me errors telling that : "Exception in thread "main" com.twilio.exception.ApiException: The requested resource /2010-04-01/Accounts/[email protected]/Messages.json was not found"

public static void main(String[] args) {
        Twilio.init("[email protected]", "mypassword");
        Message message = Message.creator(new PhoneNumber("+947XXXXXXXX"),
    new PhoneNumber("+947XXXXXXXX"), "This is the ship that made the Kessel Run in fourteen parsecs?").create();

System.out.println(message.getSid());
}

I am new to this twilio . I need expert to tell me what is the reason for this exception and how to fix it

Upvotes: 0

Views: 1168

Answers (1)

Alex Baban
Alex Baban

Reputation: 11702

It is Twilio.init(ACCOUNT_SID, AUTH_TOKEN); not Twilio.init("[email protected]", "mypassword");

You can't use your email address and your password. You can find the correct values for your ACCOUNT_SID and AUTH_TOKEN on dashboard after you login into Twilio Console at https://www.twilio.com/console

enter image description here

Twilio docs https://www.twilio.com/docs/libraries/java#testing-your-installation

// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Message message = Message.creator(new PhoneNumber("+15558675309"),
        new PhoneNumber("+15017250604"), 
        "This is the ship that made the Kessel Run in fourteen parsecs?").create();

    System.out.println(message.getSid());
  }
}

Upvotes: 2

Related Questions