I am trying to call a method using Retrofit that returns a PDF as a byte[] wrapped in a Spring ResponseEntity. Method basically just looks like this:
@Headers("Content-Type: application/pdf")
@GET("/v1/pdf")
Call<ResponseEntity<byte[]>> getPdf(
@Query("number") final String number
);
It seems like jackson has no idea how to deserialize this byte array, and upon usage:
final ResponseEntity<byte[]> pdf = service.getPdf(number).execute().body();
I get the following error:
Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `org.springframework.http.ResponseEntity` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
How should I be leveraging the client method to retrieve the ResponseEntity?
CodePudding user response:
Ended up changing the implementation of the service method to return a Spring Resource instead of a byte array directly.