Accessing response headers from tRest

Highlighted
Six Stars

Accessing response headers from tRest

Hi,

 

I need to access to my response header with tRest component, not the tRestClient.

I use ((java.util.Map<String,java.util.List<String>>)globalMap.get("tREST_1_HEADERS")).get("Set-Cookie").get(0).toString()

But I have a result of NullPointerException..

 

Maybe you'll have a solution for me, thanks


Accepted Solutions
Highlighted
Eight Stars

Re: Accessing response headers from tRest

Use a tFixedFlowInput with null values.

View solution in original post


All Replies
Highlighted
Eight Stars

Re: Accessing response headers from tRest

Hi, tREST does not have this variable. Use tRESTClient instead.

 

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

Hope it helps.

Highlighted
Six Stars

Re: Accessing response headers from tRest

Yes I know but when I use tRestClient, the problem is I need to input JSON in the body, so I use a tJavaRow or a tMap to output throught the tRestClient BUT tJavaRow or tMap need an input (an entry) too, and I do not have anything to put in entry because my JSON is generated with context data. 

 

So for the moment I have put a tFileInputDelimited with a input.txt before the tJavaRow without anything inside it, but it's not pretty... Do you have a solution, I hope you'll understand my problem.

 

Thanks 

Highlighted
Eight Stars

Re: Accessing response headers from tRest

Use a tFixedFlowInput with null values.

View solution in original post

Highlighted
Six Stars

Re: Accessing response headers from tRest

Yes thanks that's ok but it would be better if we could get the headers from a tRest...

 

Thanks

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

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

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog