Reputation: 3546
I would like to query for events. I use the following code:
final Events feed = client.events().list(myCalendar.getId()).setOrderBy("updated").set("sortOrder", "descending")
.execute();
This does not work, nevertheless.
How can I order the results descending instead of ascending?
My calendar has more than 250 events (maximum number of events returned), which is why I cannot just iterate over all events and need to do some pre-filtering.
Upvotes: 2
Views: 1258
Reputation: 116908
You need to use pagination to loop over additional rows.
import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.Event;
import com.google.api.services.calendar.model.Events;
// ...
// Initialize Calendar service with valid OAuth credentials
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
.setApplicationName("applicationName").build();
// Iterate over the events in the specified calendar
String pageToken = null;
do {
Events events = service.events().list('primary').setPageToken(pageToken).execute();
List<Event> items = events.getItems();
for (Event event : items) {
System.out.println(event.getSummary());
}
pageToken = events.getNextPageToken();
} while (pageToken != null);
You can not choose ascending or descending by default its ascending. link
"updated": Order by last modification time (ascending).
Upvotes: 1