Using JAX-RS how to collect an array of data returned by an API service into a list of java objects?

Viewed 340

What is the correct way to get List of objects from an API service using JAX-RS?

Environment: Helidon (MP 1.4.4), Java 8. The external api service returns an Array of objects. Paper is a POJO.

Client client = ClientBuilder.newClient();
...
...
public List<Paper> getPapers() {
   return client
            .target(REST_URI)
            .request(MediaType.APPLICATION_JSON)
            .header("api-key", "xxxxxx")
            .get(new GenericType<List<Paper>>() { });
}

Error:

javax.ws.rs.client.ResponseProcessingException: javax.json.bind.JsonbException: Can't deserialize JSON array into: class java.lang.String
0 Answers
Related