I have been trying to get pagination working in the java client, and I continuously get the same offset id.
The first time offset is null and it returns a data as well have an offset id for result.nextPage.offset. I then use that offset and resubmit again to get the next page. But, it endlessly returns that same response with the same offset id. Am I doing something wrong?
Here is my code:
Client client = Client.oauth(app.getOAuthApp());
String offset = null;
Map<String, Object> queries = new HashMap<>();
queries.put("name", taskName);
queries.put("completed", false);
queries.put("project", projectId);
while (true) {
ResultBodyCollection<Task> result = client.tasks.findAll()
.query(queries)
.option("offset", offset)
.option("limit", 10)
.option("page_size", 10)
.executeRaw();
if (result.nextPage != null) {
offset = result.nextPage.offset;
} else {
break;
}
}