Monday, 29 October 2018

How to do CalDav multiput delete for iCloud?

We have an iCloud calendar PHP integration that uses batch CRUD methods as detailed here: https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/calendarserver-bulk-change.txt

It appears Apple has updated their servers because since last week suddenly the integration stopped working. There were various changes we could fix, such as creating calendars and events. But <MM:delete/> does not work yet, even though I'm using the exact specs required.

Here's the body:

$body = <<<CALENDAR
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MM:multiput xmlns:D="DAV:"
           xmlns:MM="http://me.com/_namespace/"
           xmlns:C="urn:ietf:params:xml:ns:caldav">
       <MM:resource>
       <D:href>/12345678/calendars/calendarname/1234.ics</D:href>
       <MM:delete/>
   </MM:resource>
</MM:multiput>
CALENDAR;

The Guzzle request looks like this:

$response = $client->request('POST', 'https://pXX-caldav.icloud.com/{$iCloudUserId}/calendars/{$calendarName}/', [
       'auth' => [
           'user@example.com',
           'third-party-pass',
       ],
       'headers' => [
           'Content-Type' => 'application/xml; charset="utf-8',
       ],
       'body' => $body,
   ]);

The response I get is empty, it does not return 200 OK multiresponse like it did before. And nothing happens in iCloud either. It looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ns2:multistatus 
      xmlns:ns6="http://me.com/_namespace/" 
      xmlns:ns5="http://calendarserver.org/ns/" 
      xmlns:ns2="DAV:" 
      xmlns:ns4="urn:ietf:params:xml:ns:caldav" 
      xmlns:ns3="http://apple.com/ns/ical/"
    />

The strange thing is, a regular DELETE for one event works. But then we would have to fire a lot of requests to the server.

How should I do a proper multiput delete for iCloud now?



from How to do CalDav multiput delete for iCloud?

No comments:

Post a Comment