Pagination not available even when the limit parameter is specified

Briefly describe (1-2 sentences) the Bug you’re experiencing:
Pagination properties are not available when searching for tasks in a workspace, even when the limit parameter is specified in the request.

Steps to reproduce:

  1. Create a least 3 tasks in your workspace
  2. Execute GET<workspace_gid>/tasks/search?created_at.after=1970-01-01T00:00:00.000Z&opt_fields=gid,name&limit=2
  3. Response has no next_page property

Browser version: n/a

Upload screenshots below: n/a

I just tested and I believe the search endpoint is not paginated that way. I don’t get pagination info back from the server on that endpoint. I request for the next created date and if it comes back empty, I am done.

1 Like

You are right, there’s no “next_page” property. But limit works, you will get between 1 and 100 items in return when using it.

But paging using the “search” endpoint must be done using ?sort_by=created_at. Then, look at your page result, and if you asked for 100 items and you get 100 in response, there are chances there’s more.

So, use the last item “created_at”, and use it to query page 2, like:

?sort_by=created_at&created_at.before=(created_at of the last item of previous page).

Warning: Do NOT use “modified_at” to sort, use created_at, because the modified_at parameter used in that index is NOT the same as the one included in the tasks objects !! I think that it’s the modified_at when the task was added to the index engine, so it’s not safe to use it for paging.

This process is described in the “pagination” section of the “Search tasks in a workspace” documentation.


What a great answer Frederic, thanks!