Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-29903

Add a rest call to return the total number of results from a filter

    • We collect Jira feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      NOTE: This suggestion is for JIRA Server. Using JIRA Cloud? See the corresponding suggestion.

      Idea is that a user can issue a GET against:

      http://example.com:8080/jira/rest/api/2/filter/count/

      {id}

      This will return the number of issues which the filter returns.
      A similar call exists in the SOAP API here: http://docs.atlassian.com/rpc-jira-plugin/4.4/com/atlassian/jira/rpc/soap/JiraSoapService.html#getIssueCountForFilter(java.lang.String

            [JRASERVER-29903] Add a rest call to return the total number of results from a filter

            You can accomplish this with the existing REST API (since 5.0).

            Step 1: get the filter search URL

            Go to the filter's REST address. For example:

            GET https://jira.atlassian.com/rest/api/2/filter/12844

            {
              self: "https://jira.atlassian.com/rest/api/2/filter/12844",
              id: "12844",
              name: "All JIRA Bugs",
              jql: "project = 10240 AND issuetype = 1 ORDER BY key DESC",
            
              ...
            
              viewUrl: "https://jira.atlassian.com/secure/IssueNavigator.jspa?mode=hide&requestId=12844",
              searchUrl: "https://jira.atlassian.com/rest/api/2/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC",
              favourite: false
            }
            

            The searchUrl link is what you would use to see the search results.

            Step 2: run the search with maxResults=0

            Doing a GET on the searchUrl with maxResults=0 will simply return the result count.

            GET https://jira.atlassian.com/rest/api/2/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC&maxResults=0

            {
              startAt: 0,
              maxResults: 0,
              total: 13048,
              issues: [ ]
            }
            

            Luis Miranda (Inactive) added a comment - You can accomplish this with the existing REST API (since 5.0). Step 1: get the filter search URL Go to the filter's REST address. For example: GET https://jira.atlassian.com/rest/api/2/filter/12844 { self: "https: //jira.atlassian.com/ rest /api/2/filter/12844" , id: "12844" , name: "All JIRA Bugs" , jql: "project = 10240 AND issuetype = 1 ORDER BY key DESC" , ... viewUrl: "https: //jira.atlassian.com/secure/IssueNavigator.jspa?mode=hide&requestId=12844" , searchUrl: "https: //jira.atlassian.com/ rest /api/2/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC" , favourite: false } The searchUrl link is what you would use to see the search results. Step 2: run the search with maxResults=0 Doing a GET on the searchUrl with maxResults=0 will simply return the result count. GET https://jira.atlassian.com/rest/api/2/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC&maxResults=0 { startAt: 0, maxResults: 0, total: 13048, issues: [ ] }

              Unassigned Unassigned
              bberenberg Boris Berenberg (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: