protected byte[] performJIRAGetRESTCall(String restOperation, List<NameValuePair> params) throws Exception {
String url = jiraRestAPIUrlBase + restOperation;
logger.debug("Go to perform JIRA REST API call to the {} with parameters {}", url, params);
URIBuilder builder = new URIBuilder(url);
if (params != null) {
for (NameValuePair param : params) {
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);