I have a simple jql query that works from the browser but fails from java. The java will return populated results for other queries but not the simple "key=" query. If I take the url for the simple query and paste it into a browser, it will return the expected, populated json. For the simple query it returns:
{"total":0,"maxResults":50,"issues":[],"startAt":0}
Uncommenting either of the other "Sting jql=" lines they will return values in the json.
Have to assume this is something simple but I do not see it or find it in the doc.
Code snippet from simple demo app
//***************************
// String jql = "type = bug and updatedDate >= startOfMonth()";
// String jql = "project = DEMO AND type = bug AND updatedDate >= startOfDay()";
String jql = "issueKey=DEMO-28940";
String url = "https://jira.myco.com/rest/api/latest/search?jql=" + URLEncoder.encode (jql, "UTF-8");
//**the output of this println pasted into a browser returns the expected, populated json.
System.out.println(url);
HttpClient httpClient = HttpClientBuilder.create().build();
HttpGet getRequest = new HttpGet(url);
getRequest.setHeader("Authorization", "Basic " + hashedAuth);
getRequest.addHeader("accept", "application/json");
try {
HttpResponse response = httpClient.execute(getRequest);
int statusCode = response.getStatusLine().getStatusCode();
System.out.println(response.getStatusLine().getStatusCode());
//** statusCode is 200
if (statusCode == 200) {
BufferedReader br = new BufferedReader(
new InputStreamReader((response.getEntity().getContent())));
JSONParser parser = new JSONParser();
Object replyObj = parser.parse(br);
JSONObject jsonObject = (JSONObject) replyObj;
System.out.println(jsonObject.toString());
//** prints {"total":0,"maxResults":50,"issues":[],"startAt":0}