Ramaraj Karuppusamy
Ramaraj Karuppusamy

Reputation: 2360

google documents api pagination

I am using google documents API. I need to implement pagination.

I used like below.

First page:

qry.setMaxResults(10);
qry.setStartIndex(1);

Second page:

qry.setMaxResults(10);
qry.setStartIndex(11);

I am getting same 10 results for second page also.

This question has this as answer link.

I am unable to find any answer in this link. Can any one help me? Thanks in advance..

Upvotes: 1

Views: 4095

Answers (1)

Claudio Cherubino
Claudio Cherubino

Reputation: 15014

The Documents List API uses "next" tokens for pagination and not the start index:

https://developers.google.com/google-apps/documents-list/#getting_all_pages_of_documents_and_files

To retrieve all pages of documents, you start from the beginning and then follow the link with rel=next to get more pages.

The max results parameter is used to limit the number of elements in each page.

Remember you can (and should) also use the newer Drive API to perform the same task:

https://developers.google.com/drive/v2/reference/files/list

Upvotes: 3

Related Questions