core icon indicating copy to clipboard operation
core copied to clipboard

Pagination not working when querying related content by Rest API

Open muhammadfaizandotcms opened this issue 3 years ago • 2 comments

Describe the bug When using the Content API with /related, /limit, and /offset path. Changing the offset parameter does not do anything. As a result Content API always returns the same contentlets.

Related Ticket: https://dotcms.zendesk.com/agent/tickets/107332

Reproduced on: 22.03

To Reproduce Steps to reproduce the behavior:

  1. Go to http://demo.dotcms.com/api/content/render/false/query/+contentType:Destination%20+languageId:1%20+deleted:false%20+working:true/orderby/score,modDate%20desc/related/Destination.activities:574f0aec-185a-4160-9c17-6d037b298318/limit/1/offset/0.
  2. Go to http://demo.dotcms.com/api/content/render/false/query/+contentType:Destination%20+languageId:1%20+deleted:false%20+working:true/orderby/score,modDate%20desc/related/Destination.activities:574f0aec-185a-4160-9c17-6d037b298318/limit/1/offset/1.
  3. Verify the results of both api's After changing the offset result is still the same.

Expected behavior In Content API when we use /related /limit /offset. After changing the offset next page result should appear.

muhammadfaizandotcms avatar May 17 '22 13:05 muhammadfaizandotcms

They should use the POST methods as the get/url param methods are deprecated. These seem to work:

curl -XPOST 'https://demo.dotcms.com/api/content/_search' \
-H 'Content-Type: application/json' \
-d '{
"query": "+contentType:Destination +(conhost:48190c8c-42c4-46af-8d1a-0cd5db894797 conhost:SYSTEM_HOST) +languageId:1 +deleted:false +working:true",
"sort": "score,modDate desc",
"limit": 1,
"offset": 1
}'

curl -XPOST 'https://demo.dotcms.com/api/content/_search' \
-H 'Content-Type: application/json' \
-d '{
"query": "+contentType:Destination +(conhost:48190c8c-42c4-46af-8d1a-0cd5db894797 conhost:SYSTEM_HOST) +languageId:1 +deleted:false +working:true",
"sort": "score,modDate desc",
"limit": 1,
"offset": 2
}'


wezell avatar May 17 '22 13:05 wezell

Actually, looking a the above, those are not apples to apples queries. I don't know if we offer the related parameter in the post method. More discovery is needed.

wezell avatar May 17 '22 13:05 wezell

PR: https://github.com/dotCMS/core/pull/22738

nollymar avatar Aug 12 '22 15:08 nollymar

Fixed, tested on release-22.09 // Docker // FF

bryanboza avatar Aug 19 '22 21:08 bryanboza