0

Having next code, which use RestEasy to get to a Twilio CALL info:

import java.util.Base64;

import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;

import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;

import com.twilio.rest.api.v2010.account.Call;

public class RestGetCallInfo1 {

    public static void main(String[] args) {
        try {                   

            ResteasyClient client = new ResteasyClientBuilder().build();
            ResteasyWebTarget  = client.target("https://api.twilio.com/2010-04-01/Accounts/AC99999999/Calls/CA77777777777.json");

            String credentials = "AC99999999:888888888";
            String base64encoded = Base64.getEncoder().encodeToString(credentials.getBytes());
            Response response = target.request().header(HttpHeaders.AUTHORIZATION, "Basic " + base64encoded).get();
            int status = response.getStatus();          

            if (status == 200) { //OK               
                Call call = response.readEntity(Call.class); //<------------- This fails!
                System.out.println(call);               
            }

        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

}

I want to ask you:

  1. What 'Rest' libraries/tools does twilio-7.47.2-jar-with-dependencies.jar use inside (in order to use that instead of RestEasy)?

  2. How can I get the JSON call object properly? with the actual code I get:

    javax.ws.rs.ProcessingException: Unable to find a MessageBodyReader of content-type application/json and type class com.twilio.rest.api.v2010.account.Call

EDIT: I am able to get the Call info in JSon format with:

String call = response.readEntity(String.class);
JLLMNCHR
  • 1,551
  • 5
  • 24
  • 50
  • `twilio-7.47.2-jar-with-dependencies.jar` where can a reader get that JAR? Where is the twilio API documentation? – Freiheit Jan 24 '20 at 13:57
  • Related question - https://stackoverflow.com/questions/12175564/unable-to-find-a-messagebodyreader-of-content-type-application-json-and-type-cla shows how to resolve a similar error with Rest Easy – Freiheit Jan 24 '20 at 13:57

0 Answers0