Avinash Dash
Avinash Dash

Reputation: 21

TwilioRestClient for java not working

I have been trying to use the TwilioRestClient.Builder class in order to send out an sms using my Twilio number.

I have been using this piece of code within a MessageCreator class:

messageCreator = new TwilioMessageCreator(
     newTwilioRestClient.Builder(credentials.getAccountSid(),credentials.getAuthToken())
    .build()
);

However, when I use this piece of code in another class, I receive this exception:

java.lang.NoClassDefFoundError: org/apache/http/ProtocolVersion com.twilio.http.TwilioRestClient$Builder.<init>(TwilioRestClient.java:66)

This seems to indicate some problem with the TwilioRestClient.Builder() method, but I am unable to identify the issue.

I hope I can get an answer to this!

Upvotes: 2

Views: 1167

Answers (1)

Megan Speir
Megan Speir

Reputation: 3811

It is possible you are using version 6.x at the moment, the example of TwilioRestClient.Builder you are looking at is for version 7.x of the java library.

You can check here how you send messages with version 6.x: https://www.twilio.com/docs/api/rest/sending-messages

Please let me know if this helps.

Upvotes: 1

Related Questions