Hi Dustin,
you can get the cookies sent by the server by calling the
"getCookieSettings" on the response which returns a list of
CookieSetting instance.
If you want to set the cookies on the request, use the "getCookies"
method on the Request (have a look at the org.restlet.data.Cookie and
org.restlet.data.CookieSetting classes).
Client client = new Client(Protocol.HTTP);
client.get("https://...url to login....");
Response response = client.get("... another rest call....");
Representation representation = response.getEntity();
// get the cookies from the server
Series<CookieSetting> cookiesSentByServer = response.getCookieSettings();
...
//set the cookies for all new request
response = new Response(request);
request.getCookies().add(cookie);
client.handle(request, response);
...
best regards,
Thierry Boileau
Hello,
I am working with a REST-like webservice now that requires me to send a get
to a url with a username/password as query params in the url. The server then
sets a cookie, then I can invoke whatever other webservices I want as long as I
send that cookie. I can see that making the get with the username/password is
setting and returning me a cookie, but how do I make my client then make
subsequent requests with that cookie? Here is my code, much thanks,
Dustin
Client client = new Client(Protocol.HTTP);
client.get("https://...url to login....");
Representation representation = client.get("... another rest
call....").getEntity();