
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Http headers print with trest client
Hi there
Is there any way I can print Http Headers with trest client? I am trying to do like this:
System.out.println(globalMap.get("tRESTClient_1_HEADERS"));
But it is showing me null......
Is there something I am doing wrong?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
After calling a Restful service using tRESTClient, you can get the headers from the response by using tJavaRow component
Add a tJavaRow after tRESTClient, with the following code:
//access to global headers
java.util.Map resp_headers = (java.util.Map<String,java.util.List<String>>)globalMap.get("tRESTClient_1_HEADERS");
//iterate through the list of headers
System.out.println("\nResponse Headers list:");
for(String headerName: (java.util.Set<String>) resp_headers.keySet()) {
String headerValue = ((java.util.List<String>)resp_headers.get(headerName)).get(0).toString();
System.out.println("\t" + headerName + ": " + headerValue);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In a similar way how do I read result from rest client using javarow or javaflex component?
Any help would be appreciated. Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Are you referring to the JSON response of a tRESTClient POST request? It is the body column or the string column that contains the string json? If body column, it is a Document type, link tRestClient to a tXMLMap to extract the string Json, and then link the output to a tExtractJSONFields to extract the value from the string Json, the job looks like:
tRestClient--main--tXMLMap--main--tExtractJSONFields--tLogRow
If the string column contains the string json, link tRestClient to tExtractJSONFields and extract the value, the job looks like:
tRestClient--main--tExtractJSONFields--tLogRow
Feel free to let us know if it is what you are looking for.
Best regards
Sabrina

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have specific need where I need to get entire response from test client as string or object type and then start manipulating it in java.
If you could tell me how to get that using javarow or java flex, that would be fanatic.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the code.
//access to global headers java.util.Map resp_headers = (java.util.Map<String,java.util.List<String>>)globalMap.get("tRESTClient_1_HEADERS"); //iterate through the list of headers System.out.println("\nResponse Headers list:"); for(String headerName: (java.util.Set<String>) resp_headers.keySet()) { String headerValue = ((java.util.List<String>)resp_headers.get(headerName)).get(0).toString(); System.out.println("\t" + headerName + ": " + headerValue);
Above code help us in fetching the list of response headers in tRestClient, Is there is any way to fetch the request headers of tRestClient component.
Specially I am looking for custom headers that we sent in Advance Setting section of tRestClient. I am looking for code where I could fetch all request headers of tRestClient at once like above code give all response headers list and log them.
In attached picture i want to fetch all request headers intJavaRow_1 that I set in HTTP headers section of tRestClient
Screenshot from 2019-11-28 12-16-37.png
