sabre-io / dav

sabre/dav is a CalDAV, CardDAV and WebDAV framework for PHP
http://sabre.io
BSD 3-Clause "New" or "Revised" License
1.53k stars 346 forks source link

Error when creating a calendar object: "A calendar object on a CalDAV server may only have components with the same UID" #1264

Open sven-ahrens opened 4 years ago

sven-ahrens commented 4 years ago

Hey there,

I'm at a stage of my application where I wanted to test if thinks work out. So I've been trying to create a calendar object by uploading the content of an .ics file. This ics file is exported from my macOS computer.

By doing so, I get the following error message:

3.2.2 Sabre\DAV\Exception\UnsupportedMediaType Validation error in iCalendar: A calendar object on a CalDAV server may only have components with the same UID.

I've also validated this on https://icalendar.org/ but there is no error at all.

This is the content of my .ics file

BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
X-WR-CALNAME:Test
PRODID:-//Apple Inc.//Mac OS X 10.15.4//EN
X-APPLE-CALENDAR-COLOR:#F64F00
X-WR-TIMEZONE:Europe/Berlin
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
DTSTART:19810329T020000
TZNAME:MESZ
TZOFFSETTO:+0200
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
DTSTART:19961027T030000
TZNAME:MEZ
TZOFFSETTO:+0100
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20200421T142609Z
UID:70115010-1418-408E-9ECA-FF0FE1F6C066
DTEND;TZID=Europe/Berlin:20200429T100000
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SUMMARY:Test
LAST-MODIFIED:20200421T142620Z
DTSTAMP:20200421T142620Z
DTSTART;TZID=Europe/Berlin:20200429T090000
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
CREATED:20200421T142622Z
UID:FA0F60BE-464F-477B-B0C3-FCBDEB2328B3
DTEND;TZID=Europe/Berlin:20200501T100000
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SUMMARY:Blub
LAST-MODIFIED:20200421T142624Z
DTSTAMP:20200421T142624Z
DTSTART;TZID=Europe/Berlin:20200501T090000
SEQUENCE:1
END:VEVENT
END:VCALENDAR

Technical details

Version of sabre/dav: 4.1

Version of my macOS: Catalina 10.15.4

evert commented 4 years ago

In CalDAV, every event must be uploaded separately with its own PUT request. Exports often have more than 1 event, so the server will reject this. If you are comfortable with PHP, the vobject package has a way to split up these files in multiple files.

But it's also something you could potentially do manually with such a simple object. Note that METHOD:PUBLISH should also be removed before you PUT.