I had forgotten that getEvents() did not return a viewable array, you have to dig deeper in each event!
This script should return a stringified list of lists of all events that match. Just put an empty string for search to return all events between the two dates. The search is not case sensitive (you can search for dog
where an event contains Dog
)
function doGet(e){
var returnEvents = [];
var cal = CalendarApp.getCalendarById(e.parameter.calId);
var events = cal.getEvents(new Date(e.parameter.startDate), new Date(e.parameter.endDate),{search:e.parameter.search});
for (var i = 0; i<events.length; i++) {
returnEvents.push([events[i].getTitle(),events[i].getLocation(),events[i].getDescription()]);
}
return ContentService.createTextOutput(JSON.stringify(returnEvents));
}
Note the calendar service has not been completely reliable for me while testing, e.g. not always returning all results, this is between the apps script and the calendar, nothing to do with App Inventor.
Also, I left out the word return
in the last part of the script earlier, sorry about that.