Search code examples
jirajira-rest-apijqljira-rest-java-api

JIRA: How to search using "Key" Or "Issuekey"


I am making following REST API call to my JIRA instance. Am getting the total result as 1, but am not getting any values inside the issues : [ ]

JQL:

http://myjira:8080/rest/api/2/search?startAt=1&maxResults=50&fields=project,status&jql=fields project status jql project=C00195 and key=C00195-2210

But I'm getting an error response:

{"startAt":1,"maxResults":50,"total":1,"issues":[]}

Above JQL is not working in browser as well.

If we remove the key filter then it was working as expected.

Working JQL:

http://myjira:8080/rest/api/2/search?startAt=1&maxResults=50&jql=project=C00095

Response:

{"expand":"schema,names","startAt":1,"maxResults":50,"total":2175,"issues":[{"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields","id":"12560","self":"http://myjira:8080/rest/api/2/issue/12560","key":"C00095-2215","fields":{"parent":{"id":"12559","key":"C00095-2214","self":"http://myjira:8080/rest/api/2/issue/12559","fields":{"summary":"Task for tagging testing","status":

Solution

  • You need to change startAt from 1 to 0. This resource is counting from zero so by setting it to one you actually skip the single issue that was found.