How to get issue count using JQL in jira?

I need to get issue count based on filter using JQL.

for ex.

filter-> project in(ADMIN,MANGMNT) AND "Name" ~ "admin"

JQL needs to be used through REST API.

please help

2 answers

1 accepted

This widget could not be displayed.

There is no REST resource that returns ONLY the count, but you can use /rest/api/2/search?jql=YOUR_JQL_QUERY and then look at the result object. It will contain an attribute "total" which is the count you want.

Straight from the api doc:

{
    "expand": "names,schema",
    "startAt": 0,
    "maxResults": 50,
    "total": 1, // <- you want this value
    "issues": [
        {
            "expand": "",
            "id": "10001",
            "self": "http://www.example.com/jira/rest/api/2/issue/10001",
            "key": "HSP-1"
        }
    ]
}

 

Setting "maxResults=0" only returns the metadata without the rows if you're only interested in the total:

rest/api/2/search?jql=project=YOUR_PROJECT&maxResults=0
This widget could not be displayed.

Save the filter and look at it - most of the ways of viewing a filter will give you totals.

Note that JQL is NOT SQL, and it doesn't have anything to say about the results it pulls back. All it does is give other parts ofthe system list of issues to work with.

Thanks Nic.

Would you suggest an alternate way to get only count via any REST API method?

Run the filter and then write some code that adds up the totals in whatever application is you've written the REST code into

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

175 views 2 0
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