How do I retrieve issues of specific status with JQL

TomaszR July 31, 2013

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

13 votes
Answer accepted
Randall Robertson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

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.
Frank Nesse February 2, 2019

5,5 years later but still... Great tip!

Like # people like this
shubham June 6, 2019

5.10 years and still a great tip

Like # people like this
Olga Ivanova April 8, 2020

7 years 8 months later and still a great tip, thank you!

Like # people like this
2 votes
TomaszR August 7, 2013

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';

Sumukh K March 18, 2019

Thank you, this helped a lot!

2 votes
Randall Robertson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 5, 2013
You still have an = symbol in the fields statement. Change that to %3D as mentioned earlier and see what happens.
2 votes
Remigiusz Jackowski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 31, 2013

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.

TomaszR July 31, 2013

Dziekuje i pozdrawiam!

Remigiusz Jackowski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 31, 2013

Proszę bardzo :)

0 votes
Olamide Subair November 5, 2013

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

0 votes
TomaszR August 5, 2013

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'

John D_ Lewis August 22, 2018

Did you ever get this working? I'm having trouble getting the orderBy setting to work properly...

Randall Robertson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2018

@John D_ Lewis The "current query" example in the question you are asking about has field parameters in the middle of the JQL parameter, so it isn't going to work regardless of how you set up the order by clause in the JQL. Do you have an example you are working with that you want to post?

John D_ Lewis August 22, 2018

I was able to get this query to work (from a nodejs app): "https://" + user + ":" + token + "@site-name-here.atlassian.net/rest/api/latest/search?jql=project='project-name-here' ORDER BY 'key'&maxResults=100" - took me a while to get the single-quotes and spaces working properly, but now it's ironed out (and looks so simple!)

0 votes
TomaszR August 5, 2013

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

Suggest an answer

Log in or Sign up to answer