Quarkus RestClient get response from redirect

2k views Asked by At

I'm using Quarkus Rest Client to perform a GET request to an external API service. This service, however, does not directly return the resource (XML) I need to receive, but it performs a redirect to another API service which returns the resource.

When I try to navigate to the path which asks the API service for the resource (i.e. localhost:8080/hello) I get redirected to the page with the resource instead of receiving and processing it.

Putting a breakpoint after the request, shows that the part of the code after the request is never reached. Here is the code of the endpoint:

@Path("/hello")
public class GreetingResource {

  @Inject
  @RestClient
  MyService myService;

  @GET
  @Produces(MediaType.TEXT_PLAIN)
  public String hello() {
    myService.performGet();
    return "you are here"; // breakpoint here, it is never reached
  }
}

And here is the code of MyService:

@Path("/..")
@RegisterRestClient(configKey="key")
public interface MyService {

  @GET
  @Path("/..")
  @Produces(MediaType.TEXT_XML)
  String performGet(@QueryParam("c") String c, @QueryParam("d") String d);
}

I have tried to add the configuration key/mp-rest/followRedirects=true, but I still get the same problem. Also, with a path without redirects, everything works fine.

Using the native HttpURLConnection also works fine, but, since I am using Quarkus, I would like to use its features instead.

0

There are 0 answers