How do I retrieve issues of specific status with JQL

TomaszRykala picture TomaszRykala · Jul 31, 2013 · Viewed 10.9k times · Source

Entering a url, or running with curl, like:

https://<myurl>/rest/api/2/search?jql=project=<myproject>&status=closed&fields=id,key,status,project&maxResults=5

returns me 5 items in my project but with all statuses. For some reason I can't query for a specific status.

The output (part of it) is:

{
  "expand": "schema,names",
  "startAt": 0,
  "maxResults": 5,
  "total": 727,
  "issues": [
    {
      "expand": "editmeta,renderedFields,transitions,changelog,operations",
      "id": "79577",
      "self": "https://<myurl>/rest/api/2/issue/79577",
      "key": "<myproject>-774",
      "fields": {
        "project": {
          "self": "https://<myurl>/rest/api/2/project/<myproject>",
          "id": "14421",
          "key": "<myproject>",
          "name": "<myproject>",
          "avatarUrls": {
            (...)
          }
        },
        "status": {
          "self": "<myurl>/rest/api/2/status/1",
          "description": "The issue is open and ready for the assignee to start work on it.",
          "iconUrl": "https://<myurl>/images/icons/statuses/open.png",
          "name": "Open",
          "id": "1"
        }
      }
    },(...)
  ]
}

How to query for a given status? Many thanks.

Answer

dvdsmpsn picture dvdsmpsn · Aug 1, 2013

Use URL encoding on the attributes.

Perhaps use an online tool like this to URL encode your JQL from this:

project = PROJECTKEY AND status = Closed

to get this:

/rest/api/2/search?jql=project%20%3D%20PROJECTKEY%20AND%20status%20%3D%20Closed&fields=id,key,status,project&maxResults=5

The resulting JSON will be all closed issues.