Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

6 answers

1 accepted

10 votes
Answer accepted

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
Like # people like this

Nice, thanks Bill

Thanks a lot Bill!!!

Is there an straight JQL equivalent for this ?

2 votes

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?

Like Sakthivel likes this

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

Well you can could just do a normal JQL  query

issuetype = 'Test' and TestRunStatus = "pass" and assignee = <UserName>

Then tools will give a count for the query

A bit of a bodge but does tell you what you need to know

image.png

If you want to get issue count output you can setup query using generate api

for example if you want project base issue count then you can apply this rest api for that

URL :- "/rest/gadget/1.0/stats/generate.json?projectOrFilterId=jql-ORDER+BY+created+DESC&statType=project&includeResolvedIssues=true&sortDirection=desc&sortBy=total"

Hear in "projectOrFilterId" you can set your jql query and "statType" as like a groupBy.

I need to count of tickets for each project. I tried above mentioned API but it's returning me error

Invalid JQL query specified for chart \'ORDER+BY+created+DESC\'

I tried with another API  wherein projectOrFilterId=jsql-create+&gt+created and I got same issue again.

API works if I give a hardcoded project id though.

Thanks

Execute a CURL command for your project specifically like this on command line and pipe more. The first line shows "total" issues in your project

e.g

COMMAND

D:\curl -D- -u username:password -X GET -H "Content-Type: application/json" http://localhost:8081/rest/api/2/search?jql=project='ABC' | more

OUTPUT

...

...

100 501k 0 501k 0 0 501k 0 --:--:-- --:--:-- --:--:-- 892k
{"expand":"schema,names","startAt":0,"maxResults":50,"total":219,"issues":[{"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields"

....

....

I need to get the record count and then show it on confluence - is this possible?

You are in luck @namrata singhal for confluence this is built in.

1: When editing add "Jira Issue/Filter"
2: After you have made your filter. Select "Display Options" and the "Total Issue Count"

totalcount.png

Like # people like this

Is there a way to change the font type/size of the displayed count in confluence?

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