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

This widget could not be displayed.

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.
This widget could not be displayed.
You still have an = symbol in the fields statement. Change that to %3D as mentioned earlier and see what happens.
This widget could not be displayed.

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!

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

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'

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

@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?

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!)

This widget could not be displayed.

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

130 views 1 3
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