4

Why does service.list().setPageSize(pageSize) not work? It does not return list of elements with specified pageSize. Where is the problem?

EDIT

Here is example of code that does not work:

Appsactivity.Activities.List request = service.activities().list()
        .setDriveFileId(fileId)
        .setGroupingStrategy("driveUi")
        .setSource("drive.google.com")
        .setUserId("me")
        .setPageSize(pageSize);

ListActivitiesResponse response = request.execute();

do {
   response = request.execute();
   List<Activity> items = response.getActivities();        
   System.out.println(items.size());
   request.setPageToken(response.getNextPageToken());

} while (request.getPageToken() != null && request.getPageToken().length() > 0);

If I have 7 activities and pageSize = 3 than it does not return pages 3, 3, 1 as expected, but instead of it returns pages of size 6, 1.

The same problem is discussed here Issue with Google Charts API while paging table but setting pageSize directly via .set("pageSize", pageSize) and .set("page", "enable") did not help.

Another question like this app-engine-java-api-pagesize

Community
  • 1
  • 1
matoni
  • 2,479
  • 21
  • 39
  • 1
    If you want more help you should say which API you're using, which method and share the complete code. What value do you use for pageSize ? What is the issue ? Does it return a list with a different number of elements or does it return something else/nothing ? – David Jun 18 '15 at 23:02
  • Thanks for the reply. It happens when I work with **Google Apps Activity API** but I think the same applies for other services (see my post edit). – matoni Jun 21 '15 at 16:52

1 Answers1

0

I'm not sure as I am new to Google API. I have used it with Python. I think you need to append the command with .execute() and use service.list().setPageSize(pageSize).execute() . Here is the link to the source code for the script I wrote using Gmail API.

lakshayg
  • 2,053
  • 2
  • 20
  • 34