Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Accessing response headers from tRESTClient (5.6.1)

First off.. second day using Talend..  very impressed so far..  
I'm trying to access data from a REST API which uses a two call method to get some types of data.
Call 1 is a POST that requests a potentially long running activity.  The response to this call is a URL that is used to poll for completion of the call.
Call 2 is a GET that simply uses the URL returned in Call 1.
The issue is that the call back URL is in the response header of call 1.  From what i understand the headers are supposed to be put into the globalMap.  There is a FLOW tied to the first tRestClient that resolves to "((java.util.Map<String,java.util.List<String>>)globalMap.get("tRESTClient_1_HEADERS"))".  Problem is there's nothing in the globalMap by that name so the setting of the URL in call 2 gets a null pointer.  
When the job is run with "log messages" checked the expected response headers are dumped out so the data is there.
From what i can tell in the generated code it's not doing anything to put the headers into the globalmap after the call is made.  It looks to be making the post call in such a way that it wouldn't have access to the response headers at all.
There are records of this issue being fixed in 5.2.  see TESB-8944.
I had started yesterday with the Open source data integration version.  tRest in the internet toolset has the same issue.  Found discussions regarding tRESTClient in ESB toolset and tried it out in TOS Integration.  No joy.  Wondered if maybe i needed the ESB version of TOS to make this bit work.  So, DL'd the open source ESB TOS and rebuilt the job there..  Same result..  Would this operate differently in the subscribed version of ESB?
Labels (4)
4 Replies
Anonymous
Not applicable
Author

Found the issue...  The headers are put into the globalMap only if something is being done with the response payload.  For the call against this API the response payload is empty so I didn't do anything with it in the designer.   This meant the code that pulls the headers wasn't generated.
To get around this i send the empty result to a logger and took the flow output to the next tRESTClient via OnComponentOk.
_AnonymousUser
Specialist III
Specialist III

How did you tie the flow to the first tRestClient to resolve to ((java.util.Map<String,java.util.List<String>>)globalMap.get("tRESTClient_1_HEADERS"))? Debugging Java showed that the headers are in the globalMap but I can't access it...
_AnonymousUser
Specialist III
Specialist III

Ok, got it 0683p000009MACn.png
used tJavaRow like this
output_row.name = ((java.util.Map<String,java.util.List<String>>)globalMap.get("tRESTClient_1_HEADERS")).get("Set-Cookie").get(1).toString();
Anonymous
Not applicable
Author

Excellent.. I was coming in to reply that the get headers returns a map that you have to pull the needed values out of..