JIRA REST API -- How to Query On Issue Status Name

Steve Murphy picture Steve Murphy · Sep 2, 2014 · Viewed 8.9k times · Source

I'm using the JIRA REST API and I would like to query for all issues in "Resolved" status. The status field looks like this:

"status": {
      "self": "https:\/\/jira.atlas.xx.com\/rest\/api\/2\/status\/5",
      "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.",
      "iconUrl": "https:\/\/jira.atlas.xx.com\/images\/icons\/statuses\/resolved.png",
      "name": "Resolved",
      "id": "5",
      "statusCategory": {
        "self": "https:\/\/jira.atlas.xx.com\/rest\/api\/2\/statuscategory\/3",
        "id": 3,
        "key": "done",
        "colorName": "green",
        "name": "Complete"
      }
    }

Currently the only way to know to do this is to query for status=5. It would be nice to make the query more intuitive and look for all issues using the string "Resolved" status. Here is the query I'm using:

https://jira.atlas.xx.com/rest/api/2/search?jql=project=MYPROJECT and status=5 and fixVersion=15824&fields=id,key,description,status

Is it possible to query on status name?

Answer

luviktor picture luviktor · Sep 2, 2014

Yes, you can query on status name as well.

I think you should use the official Jira documentation, especially this when using advanced searching options like JQL queries.

This documentation describes every part of your possible JQL queries. If you look at the Fields reference section, there you will find the fields as well as the possible attributes on which you can search. For example, in case of Status field:

You can search by Status name or Status ID (i.e. the number that JIRA automatically allocates to a Status).

According to this, your query can be modified easily

https://jira.atlas.xx.com/rest/api/2/search?jql=project=MYPROJECT and status=Resolved and fixVersion=15824&fields=id,key,description,status