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!
}