Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-95396

Confluence REST API Pagination Issue: Inconsistencies in Pagination Functionality

    XMLWordPrintable

Details

    Description

      Issue Summary

      When using the Confluence REST API for pagination, especially with page or attachment counts exceeding 200, applying pagination using the limit and start filters may not cause the REST API to terminate even after reaching the end of the result count. Instead, it continues to provide further pagination results.

      However, if the page or attachment counts are under 200, the REST API provides the correct pagination records and terminates the API calls upon reaching the end of the result.

      This is reproducible on Data Center: (yes) 

      Affected versions:

      • 7.19.21
      • 8.5.8
      • 8.9.0

      For example, if a page contains more than 200 attachments, let's say 228, and while executing the following REST API to fetch the attachments with a limit of 50 records starting from 200.

      http://localhost:21921/c71921/rest/api/content/394288/child/attachment?limit=50&start=200 

      The above REST call produces the following result: the size parameter indicates 50 records, which is incorrect; it should be 28. Additionally, the _links parameter includes a pagination call for the next 50 records starting from 250, which is also incorrect. Given that the page has 228 attachments and the REST call starts from 200, it should not generate the _links.next parameter.

       "start": 200,
          "limit": 50,
          "size": 50,
          "_links": {
              "self": "http://localhost:21921/c71921/rest/api/content/394465/child/attachment",
              "next": "/rest/api/content/394465/child/attachment?limit=50&start=250",
              "prev": "/rest/api/content/394465/child/attachment?limit=50&start=150",
              "base": "http://localhost:21921/c71921",
              "context": "/c71921"
       

      Steps to Reproduce

      • Create a page and upload more than 200 attachments to it.
      • Use any REST API client like Postman and execute the following REST call. Set the parameters limit to 50 and start at 200. This indicates that the REST API result should contain 50 results, starting from 200.
        http://localhost:21921/c71921/rest/api/content/394465/child/attachment?limit=50&start=200 
      • As the page has 228 attachments, the above REST call should terminate after this call and provide a result size of 28. However, it continues to provide results according to the configured limit and proceeds to fetch additional records.
            "start": 200,
            "limit": 50,
            "size": 50,
            "_links": {
                "self": "http://localhost:21921/c71921/rest/api/content/394465/child/attachment",
                "next": "/rest/api/content/394465/child/attachment?limit=50&start=250",
                "prev": "/rest/api/content/394465/child/attachment?limit=50&start=150",
                "base": "http://localhost:21921/c71921",
                "context": "/c71921" 
      • It seems Confluence now generates batches without terminating the call even if it reaches the end of the result count. 

      Expected Results

      If the REST call reaches the end of the result count, it should provide the following result without adding the _link.next and the correct size of the result.

      "start": 200,
          "limit": 50,
          "size": 28,
          "_links": {
              "self": "http://localhost:21921/c71921/rest/api/content/394288/child/attachment",
              "prev": "/rest/api/content/394288/child/attachment?limit=50&start=150",
              "base": "http://localhost:21921/c71921",
              "context": "/c71921" 

      Actual Results

      It provides the result further even if it is reached at the end of the result. Adding the _link.next and size is also not correct.

      Workaround

      Currently, there is no known workaround for this behavior. A workaround will be added here when available

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hgupta@atlassian.com Hemant Gupta
              Votes:
              10 Vote for this issue
              Watchers:
              23 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: