Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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);
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
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