We have a locally hosted JIRA instance. When I perform a REST call using a browser based REST client, I get the data, when I perform the same call from a Java application, I get no data (the connection shows successful as well as the login - e.g. the status is 200).
The relevant code is here:
private CloseableHttpClient buildClient()
{
CredentialsProvider credentials = new BasicCredentialsProvider();
credentials.setCredentials(AuthScope.ANY, new NTCredentials(uid, pwd, baseURL, domain));
return HttpClients.custom().setDefaultCredentialsProvider(credentials).build();
}
public String post(Holder<Boolean> success, String url, String request) throws UnsupportedEncodingException, IOException
{
CloseableHttpClient client = buildClient();
HttpPost post = new HttpPost(baseURL + url);
post.setHeader("Content-Type", "application/json;charset=UTF-8");
post.setEntity(new StringEntity(request));
CloseableHttpResponse response = client.execute(post);
if (response.getStatusLine().getStatusCode() == 200)
{
String text = EntityUtils.toString(response.getEntity());
response.close();
client.close();
success.value = true;
return text;
}
else
{
response.close();
client.close();
success.value = false;
return response.getStatusLine().getReasonPhrase();
}
}
The url I'm using is http://<server>/rest/api/2/search and the request is { "jql" : "status=Closed' }