I have something like this:
@RestController
public class MyController {
@GetMapping("/myAddress")
public Response generateReportAsync(...) {
...
}
}
This web service generates a report file according to the Accept
header requested (pdf, xls, csv...). Since the generation is performed asynchronously, the response returned is actually a JSON at first and the report is made accessible later.
My problem is that when I invoke this passing an Accept
header like application/pdf
I receive a 406 back since the WS replies with a JSON. Is there any way I can force a JSON reply with any Accept
header I receive only for this specific mapping?
I've tried playing around with the produces
and consumes
properties on the GetMapping
annotations without luck. Other answers I've found use a global configuration or mess with the HttpResponse
. If possible I'd like to use a more declarative approach with annotations.
Thanks!