How do I retrieve issues of specific status with JQL

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.

7 answers

1 accepted

Your parentheses need to be properly encoded:

( = %28

) = %29

An easy way to get the proper encoding is to

  1. build your search in JIRA first
  2. When you have the results you want, click the Views button in Issue Navigator
  3. Right-click the XML link and copy the link address. It has all the proper formatting already.
  4. Paste everything that comes after 'jqlQuery=' into your code and add your variables and such.
You still have an = symbol in the fields statement. Change that to %3D as mentioned earlier and see what happens.

JQL for statuses:

status in (resolved)

In your example

https://<myurl>/rest/api/2/search?jql=project IN (<myproject>) AND status in (resolved)&fields=id,key,status,project&maxResults=5

Please, don't use "=" in URLs variables. Change them to %3D or use "IN". You can use URLencode to get rid of them.

https://<myurl>/rest/api/2/search?jql=project%3D<myproject>%20AND%20status%3Dresolved&fields=id,key,status,project&maxResults=5

When you search for issue in JIRA's Issue Browser, you can click "Advanced" link, to show current query as JQL.

Dziekuje i pozdrawiam!

YES! Finally got it working, thank you!!

$url = 'https://<oururl>.jira.com/rest/api/2/search?jql=project%20%3D%20<ourteam>%20AND%20status%20in%20(%22In%20Analysis%22%2C%20%22In%20Development%22)%20ORDER%20BY%20priority%20DESC%2C%20status%20DESC&fields%3Did,key,summary,priority,status,project,assignee';

Hi, could you help me with this please? I can't get my results to sort.

...&fields=id,key,summary,priority,status,project,assignee%20order%20by%20priority%20asc

doesn't sort my results by priosity in ascending order for example

Still doesn't help. My items are always sorted by ID descending.

Current query:

$url = 'https://<oursite>.jira.com/rest/api/2/search?jql=project%3D' . $TEAM . '%20AND%20status%20IN%20(%22in%20analysis%22,%22in%20development%22)&fields%3Did,key,summary,priority,status,project,assignee%20ORDER%20BY%20priority,status%20asc'

@Tomasz Rykala , is the 'jira.com' bit necessary?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,965 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot