Manage cookie between 2 http requests

Highlighted
Eight Stars

Manage cookie between 2 http requests

Hi

 

In a ESB route I'm using cHttp POST to connect to a https server. Then my 2nd request is to post data to that server. I added the certificate in my JVM , it works in a tool like Postman or Insomnia but not in my route because I guess the session cookie we get after the first call is not included in the 2nd one, than I get a 401 forbidden error. 

What is the solution to keep cookie from first to second https requests ? 

 

Loko

Tags (2)
Employee

Re: Manage cookie between 2 http requests

Hi,

 

    Could you please try to call a DI job as shown in below scenario?

 

https://help.talend.com/reader/wPJh3yAxz0baR8imIwmlYA/X1kCQaKtALDIocZ0p6QjpA

 

A sample scenario about handling cookies can be referred from below link.

 

https://help.talend.com/reader/wDRBNUuxk629sNcI0dNYaA/1VRELvm1ibYLFfM5pqaHZg

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Eight Stars

Re: Manage cookie between 2 http requests

Hi

We don't want to use jobs. We work with route, and Talend itself says calling a job via cJob is not a good solution because of performance issues.

I tried this code just at the moment ans it works (send back the "Set-Cookie" camel header as "cookie", substring to remove the brackets) 

String cookieString = exchange.getIn().getHeader("Set-Cookie", String.class);
exchange.getIn().setHeader("Cookie", cookieString.substring(1,  cookieString.length()-2) );

But I wonder if there is any built-in and more robust solution. I believe the route itself should automatically manage cookies by default , as Camel does.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read