We have a Confluence Forge app with custom UI.
We are facing an issue when fetching paginated comments for pages and blog posts using the following APIs:
- For pages:
/wiki/api/v2/pages/{pageId}/footer-comments?sort=-created-date&limit=10&body-format=atlas_doc_format - For blog posts:
/wiki/api/v2/blogposts/{blogPostId}/footer-comments?sort=-created-date&limit=10&body-format=atlas_doc_format
Use case:
We need to display the latest 10 comments initially and then fetch more comments on demand using the _links.next URL.
Problem:
Pagination works correctly for the first two pages, but from page 3 onward, duplicate comment IDs reappear from earlier pages (e.g., comments from page 1 show up again). As a result, some comments are duplicated while others are missing.
Example (assuming 50 comments with IDs 1–50):
- Page 1 → IDs 41–50 (correct)
- Page 2 → IDs 31–40 (correct)
- Page 3 → mix of IDs 21–30 and some IDs from 41–50 (incorrect – duplicates from page 1)
This issue only occurs when we add sort=-created-date. If we omit sort and just use limit=10&body-format=atlas_doc_format, the pagination works as expected.
Questions:
- Is this a known issue with the comments API when using
sort=-created-date? - Am I misusing the API, or is there an alternate approach to achieve correct descending pagination of comments without duplicates?