Providing additional context in addition to the answer below that helped me get this done:
String str[] = ((java.util.Map)globalMap.get("tRESTClient_1_HEADERS")).get("Set-Cookie").toString().replace("[","").replace("]","").replace(",",";").split("; ");
String out = "";
for(int index = 0; index < str.length; index++){
if(str[index].startsWith("JSESSIONID=") || str[index].startsWith("CSRFToken=") || str[index].startsWith("SecurityTokenURL=")){
out = out + str[index] + "; ";
}
};
globalMap.put("cookie", out);
Assign the elements of the cookie to variable called cookie.
5. Pass the cookie into your next REST call:
I hope this helps along the next person who needs a little assistant.
I'm working on a pretty straight forward proof of concept to log-in via a POST action using Talend.
From the application side, I use a POST with a body to then receive a cookie. However, I'm at a loss for how to get the cookie details from the response of the endpoint.
In my forum lurking, there appear to be two approaches: one using tREST, the other using tRESTClient.
Using tREST, I can successfully post to the endpoint, but I can not appear to retrieve the response header or body:
This is the tREST component properties:
The cookie passed from this call needs to be recycled into subsequent calls in order for them to authenticate.
I'm hoping to understand how to get the Cookie out and passed along, either with tREST or tRESTClient. My issue with tRESTClient is that I do not have a way to pass the body to that component.
Any thoughts?
On your last point - you can pass the body to tRestClient by having a flow going into tRestClient. That flow can have a "string" field containing the body in json format, and that field will need to map to the "string" column in the component input schema. If, in your case, you do not already have a flow containing the body, you can generate it by using the tFixedFlowInput component.