Capture the HTTP response code
If you enable the option "Save HTTP Code into Global Variable" when configuring the HTTP connection, the system will capture the HTTP response code and store it in the thread-safe global variable http_processor_last_http_code
.
To access this global variable use the following JavaScript code:
importPackage(com.toolsverse.config);
var httpCode = SystemConfig.instance().getContextProperties().
get("http_processor_last_http_code"));
The last HTTP response code is valid only within the current execution thread and will be overridden on a next HTTP call so if you do want to capture it, you must execute the JavaScript code above right after the HTTP call.
Capture the response headers
If you enable the option "Save Response Headers into Global Variable" when configuring the HTTP connection, the system will capture the HTTP response code and store it in the thread-safe global variable http_processor_last_last_response_headers
.
To access this global variable use the following JavaScript code:
importPackage(com.toolsverse.config);
var headers = SystemConfig.instance().getContextProperties().
get("http_processor_last_response_headers");
// headers is a key=value String
// It must be converted to java.util.Properties
var theHeaders = Utils.getProperties(headers);
// this code just prints available headers
for each (var entry in theHeaders.entrySet()) {
etlConfig.log(entry.getKey() + "=" + entry.getValue());
}
// use theHeaders.getProperty("header name") to access the header value
The value of this variable is valid only within the current execution thread and will be overridden on a next HTTP call so if you do want to capture the response headers you must execute the JavaScript code above right after the HTTP call.
Comments
0 comments
Please sign in to leave a comment.