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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
root
Creator II
Creator II

How to capture X-Forwarded-For (tRestRequest)

Hi, I am using tRestRequest. I want to capture " X-Forwarded-For" parameter from the header of the incoming message.
When I am adding that parameter in tRestRequest, it does not allow me to do that. Please advise. Thank you.
0683p000009MDhJ.png
0683p000009MDLg.png 
Labels (3)
7 Replies
vapukov
Master II
Master II

X-Forwarded-For

illegal name for column - Talend (Java) not accept some characters in names - "-", space and etc
atelesh
Contributor
Contributor

sorry, seems no chance. there is an issue with the same roots - https://jira.talendforge.org/browse/TESB-13797 - consider please vote for it.
Anonymous
Not applicable

In meantime check request context properties such as "ALL_HEADER_PARAMS" and "ALL_QUERY_PARAMS"
thanks, Sergey
atelesh
Contributor
Contributor

yes, indeed!
thanks for the hint, Sergey!
forgot I already answered such question (even several times 0683p000009MACn.png).
so please try following way to retrieve the header in tJavaRow or tJavaFlex component right after tRESTRequest component:
((javax.ws.rs.core.MultivaluedMap<String, String>) ((java.util.Map<String, Object>) globalMap.get("restRequest")).get("ALL_HEADER_PARAMS")).getFirst("X-Forwarded-For")
root
Creator II
Creator II
Author

yes, indeed!
thanks for the hint, Sergey!
forgot I already answered such question (even several times 0683p000009MACn.png).
so please try following way to retrieve the header in tJavaRow or tJavaFlex component right after tRESTRequest component:
((javax.ws.rs.core.MultivaluedMap<String, String>) ((java.util.Map<String, Object>) globalMap.get("restRequest")).get("ALL_HEADER_PARAMS")).getFirst("X-Forwarded-For")


Sergey, atelesh:
This works, Thank you.... 
Anonymous
Not applicable

It could be really helpful if Talend has some facade pattern for this king of access either like:
InboundContext.getHeaders.getXForwardFor()
or 
InboundContext.getHeaders.get("Name")
I love the tree metadata information of the inbound and outbound contexts for example in Oracle Service Bus, here in Talend it is not that well organized and easily accessible.
atelesh
Contributor
Contributor

headers map can be easily exposed using component variables regular way in Studio.
(actually message context also - as more generic way)
Alex