SabreDAV Client create calendar object

802 Views Asked by At

I'm try to add an calendar opject into my SabreDAV server. From an existing client (like iOS or iCalendar on OSX) this works great. But when trying to add a new calendar object I get the following error:

Sabre\CalDAV\Exception\InvalidComponentType iCalendar objects must at least have a component of type

vcal->serialize has the following output:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Sabre//Sabre VObject 4.1.2//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
UID:sabre-vobject-62abb501-ad16-459b-8891-31e33cf5e9f2
DTSTAMP:20180922T111429Z
SUMMARY:hey
DTSTART;TZID=Europe/Amsterdam:20180922T095000
DTEND;TZID=Europe/Amsterdam:32000922T153800
ATTENDEE:mailto:[email protected]
END:VEVENT
END:VCALENDAR

The code I use for adding a request:

$datetime = date('Y-m-d H:i:s');
$begin = new \DateTime(date('Y-m-d H:i:s', strtotime($datetime ."-30 minutes")), new \DateTimeZone('Europe/Amsterdam'));
$end = new \DateTime(strtotime(date('Y-m-d H:i:s', strtotime($datetime))), new \DateTimeZone('Europe/Amsterdam'));

require('vendor/sabre/autoload.php');
$vcal = new \Sabre\VObject\Component\VCalendar();
$vevent = $vcal->add('VEVENT');

$vevent->add('SUMMARY', 'hey');
$vevent->add('DTSTART', $begin);
$vevent->add('DTEND', $end);

$vevent->add('ATTENDEE', 'mailto:[email protected]');

$this->davClient->request('PUT', 'calendars/admin/Rekenen/'.uniqid().'.ics', $vcal->serialize());
1

There are 1 best solutions below

0
On

Don't know if this is the root cause of the issue but your DTSTART and DTEND do reference a timezone with TZID "Europe/Amsterdam" while your iCalendar stream does not include a corresponding VTIMEZONE component that would give the definition of this timezone.

BEGIN:VCALENDAR
...
BEGIN:VTIMEZONE
...
END:VTIMEZONE
BEGIN:VEVENT
...
END:VEVENT
END:VCALENDAR

Some servers do accept such reference without definition while some others do not.