Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

13 votes
Answer 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.

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

Like # people like this

5.10 years and still a great tip

Like # people like this

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

Like # people like this

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!

You still have an = symbol in the fields statement. Change that to %3D as mentioned earlier and see what happens.

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

Thank you, this helped a lot!

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'

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

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

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you