David
David

Reputation: 101

Google Tasks API - getNextPageToken always return null

I have ~200 tasks in my gmail account. I am using the Google Tasks API (https://developers.google.com/google-apps/tasks/v1/reference/tasks/list)

The api only returns the first 100 tasks. According to the documentation, getNextPageToken() should return the nextpagetoken. However, it always return null even I have more than 100 tasks.

Here is the code for reference:

Tasks tasks_result = client.tasks().list(strList).setFields("items(completed,due,id,notes,status,title,updated)").execute();

Tasks  tasks =  tasks_result.getItems();
String nextPageToken;
do 
  {

  for (Task task : tasks) {
   ......
 }

nextPageToken = tasks_result.getNextPageToken();    <===== It always return null, WHY?????
} while (nextPageToken!=null);

Please help.

Upvotes: 2

Views: 1254

Answers (1)

David
David

Reputation: 101

Finally, I found the answer. The nextPageToken field must be specified in setFields, here is the example.

Tasks tasks_result = client.tasks().list(strList).setFields("etag,items(completed,deleted,due,notes,status,title,updated),kind,nextPageToken").execute();

Upvotes: 6

Related Questions