tRestRequest HTTP headers (IP address/ hostname/ client details)

Four Stars

tRestRequest HTTP headers (IP address/ hostname/ client details)

Hello!

I want to capture source request information (IP address/ hostname/ client details)[HTTP headers ] when I use tRestRequest.

Please help, how I can do it?

Moderator

Re: tRestRequest HTTP headers (IP address/ hostname/ client details)

Hello,

You can access individual headers by adding parameters in a schema editor and adding a 'header' to the Comment field. tRESTRequest also sets the map of all the headers it receives as a context var which means All HTTP headers are available as a map on the request context.

Bestr 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.
Four Stars

Re: tRestRequest HTTP headers (IP address/ hostname/ client details)

I added 'header' in a schema editor to the Comment field:

 

image.png

image.pngimage.pngimage.png

Nine Stars

Re: tRestRequest HTTP headers (IP address/ hostname/ client details)

Hi,

 

In field column, you have to set the name of your header value.

 

Eric

Four Stars

Re: tRestRequest HTTP headers (IP address/ hostname/ client details)

Field column does not accept dash, for example: how I can get X-Forwarded-For?

Nine Stars

Re: tRestRequest HTTP headers (IP address/ hostname/ client details)

Hi,

 

With this piece of code in a tJavaFlex, you can get your header value (In my example, header name is NAME-TEST):

java.util.Map<String, java.util.Map<String, List<String>>> restReq =
(java.util.Map<String, java.util.Map<String, List<String>>>)globalMap.get("restRequest");
java.util.Map<String, List<String>> headers = restReq.get("ALL_HEADER_PARAMS");
List<String> myheader = headers.get("NAME-TEST");
String headervalue = myheader.get(0);
System.out.println(headervalue);

 

Eric

Four Stars

Re: tRestRequest HTTP headers (IP address/ hostname/ client details)

Thx, I know this method, but I think it is not true way. It is stop gap solutions)

Eight Stars

Re: tRestRequest HTTP headers (IP address/ hostname/ client details)

yeah, there is no "native" support for capturing these fields. Even I am currently using the stop-gap alternative.

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

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