1

The code below works, so I know I'm getting the right response text:

{"id":2,"name":"Liverpool"}

However I want to put the response into a Location class. Thats when I get the problem. If i uncomment this line

List <Location> location = response.readEntity(new GenericType<List<Location>>() {});

I get the problem (Ie ven get a problem if I dont wrap Location in a List)

javax.ws.rs.ProcessingException: Unable to find a MessageBodyReader of content-type application/json;charset=utf-8 and type interface java.util.List

any ideas?

@Test
public void testList() throws IOException {

//        Client client = ClientBuilder.newClient();

    Client client = ClientBuilder.newBuilder().build();
    WebTarget target = client.target("http://localhost:9000/location/1");
    Response response = target.request().get();
String value = response.readEntity(String.class);
    //List <Location> location = response.readEntity(new GenericType<List<Location>>() {});
    System.out.println(value);
   // System.out.println(location.size());
    response.close();  // You should close connections!
}
Storms786
  • 416
  • 1
  • 7
  • 20
  • give a look at this response http://stackoverflow.com/a/13745714/2015318 – StarsSky Mar 20 '16 at 12:51
  • Thanks, that worked! Much appreciated – Storms786 Mar 20 '16 at 13:04
  • 2
    Possible duplicate of [Unable to find a MessageBodyReader of content-type application/json and type class java.lang.String](http://stackoverflow.com/questions/12175564/unable-to-find-a-messagebodyreader-of-content-type-application-json-and-type-cla) – tddmonkey Mar 20 '16 at 14:28

0 Answers0