How to get tREST HTTP header value from property file.

Highlighted
Five Stars

How to get tREST HTTP header value from property file.

Hi.

I'm calling a web service API using a tREST component.

HTTP request header contains an authentication token.

 

I want to set this dynamically by reading it from a file instead of the built-in.

What should i do?

 

Thank you.

 

コメント 2019-09-17 154330.png

Moderator

Re: How to get tREST HTTP header value from property file.

Hello,

You could access to your response header with tRESTClient.

((java.util.Map<String,java.util.List<String>>)globalMap.get("tRESTClient_1_HEADERS"))

 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.
Fifteen Stars TRF
Fifteen Stars

Re: How to get tREST HTTP header value from property file.

Get the token from the file with the following subjob to populate a global variable (for example a global variable called "token"):

tFileInputDelimited --> tFlowToIterate (do not use "default" to decide by yourself for the variable name).

Then in the tRest's value for the Value field, get the global variable value with the followinb expression:

(String)globalMap.get("token")

TRF
Five Stars

Re: How to get tREST HTTP header value from property file.

I don't have enough skills to see this and create a job...
Does the key read from the file?

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

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog