trying to return pdf or json with ByteArrayResource in webflux Mono

Viewed 20

New to webflux and got a task. I am returning pdf right now with ByteArrayResource. Downstream service can also provide json in times. If any error occurred.

Right now I have :

public Mono<ByteArrayResource> downloadReport(){

    return reactiveClient
      .get(uriBuilder -> uriBuilder.queryParam("userId",userId)
      .build(requestId))
      .uri()
      .accept(APPLICATION_PDF, APPLICATION_JSON)
      .retrive()
      .bodyToMono(ByteArrayResource.class);
}

With this code in postman error comes in json format but contentType is shown as application/octet-stream. Any idea how to get application/json?

Any suggestion??? Help is greatly appreciated.

0 Answers
Related