try {
String url = restAPIUrlBase + restOperation;
logger.debug("Go to perform ES REST API call to the {} with parameters {}", url, requestParams);
URIBuilder builder = new URIBuilder(url);
if (requestParams != null) {
for (NameValuePair param : requestParams) {
builder.addParameter(param.getName(), param.getValue());
}
}
HttpGet method = new HttpGet(builder.build());
method.addHeader("Accept", "application/json");
try {
// Preemptive authentication enabled - see
// http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html#d5e1032
HttpHost targetHost = new HttpHost(builder.getHost(), builder.getPort(), builder.getScheme());
AuthCache authCache = new BasicAuthCache();
BasicScheme basicAuth = new BasicScheme();
authCache.put(targetHost, basicAuth);
BasicHttpContext localcontext = new BasicHttpContext();
localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);