google-calendar-apiicalendar

Creating a .ics file for classes schedule


I currently have an .ics file, which is to be used as a schedule for my classes. It should contain all the classes, their duration and starting time, and repeat weekly (but, if Class X is at 9:00 both Monday and Tuesday, and at 10:00 on a Thursday, this makes 2 seperate events with different UIDs but same Summary) until Y date. Upon testing this, and adding it to Google Calendar, an error shows up: "Added Z of [TOTAL] events". I have managed to reproduce the error (in this case, "Added 1 of 2 events") with the following events:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//2 2017/2018//PT
BEGIN:VEVENT
UID:0
DTSTAMP:20180713T132719
DTSTART:20180219T100000
SUMMARY:Class 1
LOCATION:Location 1
DURATION:PT1H30M
RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20180601T000000;WKST=SU;BYDAY=MO
END:VEVENT
BEGIN:VEVENT
UID:11
DTSTAMP:20180713T132719
DTSTART:20180221T080000
SUMMARY:Class 2
LOCATION:Location 2
DURATION:PT1H30M
RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20180601T000000;WKST=SU;BYDAY=WE
END:VEVENT
END:VCALENDAR

Only the second event gets correctly added to Google Calendar. Why? If I strip away the event for Class 2, the icalendar validator shows no errors. There also aren't any errors (in the validator) with the 2 events.

Any pointers to the right direction are greatly appreciated.


Solution

  • Change your UID's to something that is guaranteed to be unique (or at least not zero). See https://www.kanzaki.com/docs/ical/uid.html

    I changed the UID's in your file after checking that yes the one with UID=0 did not load. Both events then loaded.

    For my ics files I use the website url plus a unique identifier (eg for wordpress sites, it's the post id added to the wp url)