I'm working with Google's CalDAV functionality and am having issues when trying to update an event on a calendar.
I'm receiving a "405 - Method Not Allowed" response on my PUT requests.
$calendar = 'BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
X-WR-CALNAME:Primary Calendar
X-WR-TIMEZONE:America/New_York
BEGIN:VTIMEZONE
TZID:America/New_York
X-LIC-LOCATION:America/New_York
BEGIN:DAYLIGHT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;VALUE=DATE:20181010
DTEND;VALUE=DATE:20181011
DTSTAMP:20181016T192214Z
ORGANIZER;CN=cest@tave.wtf:mailto:cest@tave.wtf
UID:076e0pqgifk0vli961dojq886p@google.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS- ACTION;CN=kody@tave.com;X-NUM-GUESTS=0:mailto:kody@tave.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ- PARTICIPANT;PARTSTAT=ACCEPTED;CN=cest457@tave.wtf;X-NUM-GUESTS=0:mailto:cest457@tave.wtf
CREATED:20181016T132132Z
DESCRIPTION:this is a description from caldav too
LAST-MODIFIED:20181016T192214Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:test google event 2, updated in caldav stuff
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR';
$url = 'https://apidata.googleusercontent.com/caldav/v2/' . $GoogleCalendarSync->calendarID . '/events';
$opts = [
'allow_redirects' => true,
'timeout' => 40,
'connect_timeout' => 10,
'headers' => [
'Authorization' => 'Bearer ' . $this->config['token']['access_token'],
'If-None-Match' => '*',
'Content-Type' => 'text/calendar',
],
'body' => $calendar,
];
$Client = new GuzzleHttp\Client();
try {
$Response = $Client->request('PUT', $url, $opts);
} catch (Exception $e) {
App::recoverableError(__METHOD__, 'Failed to update calendar', [
'exception' => $e,
'GoogleCalendarSync' => (array) $GoogleCalendarSync,
]);
return false;
}
return (string) $Response->getBody();
I'm not sure if the wrong URL is being used, although I believe it is the correct one. (If not, where could I find it?) Google's documentation is extremely limited here.
I've also verified that the access token (generated via the OAuth flow) is indeed correct since I'm also using it to successfully retrieve the calendar in another separate request. It's just the "PUT" requests that are causing the issues.
Thanks for your time!