One Star

Send session cookies along with a Rest API POST call

Hi,
I need to make a call to a Rest API which needs a cookie to be sent along with the header parameters. I was able to get the cookie using the tFileFetch component, but I am unable to set the cookies and make the second call to the ResT API. I need to send a Json object as an input parameter to the call.
I read on the couple of forums that i can set the cookies as header parameter in the advanced settings tab of a tRestClient, but I was not successful with it (may be I did not do it the right way).
Any help would be highly appreciated.
Thanks,
Dhruv
3 REPLIES
Moderator

Re: Send session cookies along with a Rest API POST call

Hi Dhruv,
Have you already checked component reference with scenarios TalendHelpCenter:tRESTClient?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Send session cookies along with a Rest API POST call

Hi Sabrina,
Yes, I did check the component reference guide but I couldn't find a solution to my problem. I know we can pass cookies as header parameters from the Advanced Setting tab but the component does not allow me to read the cookies which tFileFetch component created, right or I am missing something here. I used a work worked around for this, I made the first Rest call using a Java class in the routines and extracted the cookies it saved. I then used the cookie values and passed them as header parameters in the tRestClient call. If there is a better way to do this?
Thanks,
Dhruv
Four Stars

Re: Send session cookies along with a Rest API POST call

Follow below process. 1) Pass the credential to the string column of the 1st tRestClient (login page). 2) Capture the cookie using "((java.util.Map>)globalMap.get("tRESTClient_1_HEADERS")).get("Set-Cookie").get(1)" 3) In 2nd tRestClient component go to advance properties and add the below header properties. Name Value "Cookies" ((java.util.Map>)globalMap.get("tRESTClient_1_HEADERS")).get("Set-Cookie").get(1) you should be able to connect using above process