users@jersey.java.net

[Jersey] Re: Client not following redirects

From: Robert DiFalco <robert.difalco_at_gmail.com>
Date: Thu, 11 Jun 2015 13:37:16 -0700

In the code about it looks like you are disabling automatic redirects in
the client.

On Thu, Jun 11, 2015 at 1:01 PM, Joe Mifsud <jmif96_at_gmail.com> wrote:

> Hi all,
>
> I have a very simple implementation of a Jersey 2.18 client (pasted
> below). I’m using the standard Jersey connector (not importing any others)
> but for a simple request (also pasted below) the response I’m receiving is
> a 302 redirect. My understanding is the client should be transparently
> following these and I should receive the 200 back. Am I misunderstanding
> something? Implementing something wrong?
>
> Thanks,
> Joe Mifsud
>
> JacksonJsonProvider jsonProvider = new JacksonJsonProvider(new ObjectMapper());
>
> _client = ClientBuilder.newClient(new ClientConfig());
> _client.register(jsonProvider);
> _client.property(ClientProperties.FOLLOW_REDIRECTS, false);
>
> _baseTarget = _client.target(“..”)
>
> WebTarget target = _baseTarget
> .queryParam(“…”, “…”)
>
> Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON_TYPE);
> Response response = builder.get();
>
>
>
> —
> Sent from Mailbox <https://www.dropbox.com/mailbox>
>