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}
I do not understand the underlaying issue, however it has to do with privileges. Granting the user specific rights to the project enabled "issueKey=".
We were able to address the issue by adjusting Jira privileges for the querying user.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A good point how to start debugging is using a REST Client. I can recommend the "Rest Client" Extension for Firefox - but there are many others out there.
Then copy the Jira request 1:1 to the REST Bowser and see what happens. And vice versa.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply. Reproduced identical results via postman.
I do not believe this is a client side issue per se. The service returns a response and a 200 status.
Appears any working query starts to fail if the issueKey=DEMO-28940 phrase is added to a REST call.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.