I am trying to write a library that accesses a RESTful web service using the Jersey Client API. The service requires a login request that sets a cookie, then subsequent req
Perhaps you need to fit cookies into a WebResource call that had been working previously without them. Then you might find yourself breaking up your line of code that you can work with the builder part way through. To include cookies, your code might go from:
clientResponse = webResource.queryParams(parameters).type(httpContentType).accept(httpAcceptType).post(ClientResponse.class, requestBody);
To:
builder = webResource.queryParams(parameters).type(httpContentType);
if (cookieJar != null)
{
for (Cookie c : cookieJar)
builder = builder.cookie(c);
}
clientResponse = builder.accept(httpAcceptType).post(ClientResponse.class, requestBody);