0

I developed a client for iCloud calendar service that uses CalDAV protocol. I use caldav4j library for Java, however the problem I encountered is language/library independent. Several days ago creating of new calendars in my client stopped working. Now, I get 412 Precondition Failed status code while sending MKCALENDAR requests to iCloud. Other operations, like getting list of calendar resources, getting events, creating and updating events work the same as before.

I tried also to CURL it and to use Postman to send similar requests and results are always the same - 412 Precondition Failed. Example request send by my client to create new calendar looks like this:

MKCALENDAR /xxxxxxxxxx/calendars/2321321CH34CHU35Y4UI5YVU31TIBCYTUIYBUI3 
HTTP/1.1
Host: caldav.icloud.com
Content-Type: text/xml
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
cache-control: no-cache    
<?xml version="1.0" encoding="UTF-8"?>
<C:mkcalendar xmlns:C="urn:ietf:params:xml:ns:caldav">
<D:set xmlns:D="DAV:">
    <D:prop>
        <D:displayname>new calendar</D:displayname>
        <C:calendar-description xml:lang="en">my description</C:calendar-description>
    </D:prop>
</D:set>
</C:mkcalendar>

Parts with xxxxx contains my proper principal id and authorization token.

Does anybody know if Apple has changed there something recently? I'm sure I didn't changed anything in my code and requests like the one in example above worked successfully a few days ago.

  • What does the 412 response body contain? – hnh Nov 26 '18 at 22:45
  • Looks like dupe of https://stackoverflow.com/questions/53305100/caldav-client-for-icloud-mkcol-fails-with-412-precondition-failed – hnh Nov 26 '18 at 22:51
  • @hnh the response body is empty. The https://stackoverflow.com/questions/53305100/caldav-client-for-icloud-mkcol-fails-with-412-precondition-failed is about different method (MKCOL vs. MKCALENDAR). In my case, MKCOL works flawlessly. I have problems only with MKCALENDAR requests. They used to work properly, but stopped some short time ago. According to RFC CalDAV document MKCALENDAR is a proper method for creating calendar resources. MKCOL is more general method related to WebDAV protocol and can be used to create different types of resources. – Bartek Małachowski Nov 26 '18 at 23:13
  • Are you hitting `caldav.icloud.com` or the proper partition? `MKCALENDAR` or `MKCOL` (w/ resource-type) should not matter, they are the same thing in both questions. I added an answer to the other question, that should fix it for you as well. Tried it w/ Calendar.app which uses `MKCALENDAR` and works just fine against the proper endpoint. – hnh Nov 26 '18 at 23:19
  • I have been using randomly chosen `pXX-caldav.icloud.com` partitions because I didn't know that I can use calendar-home-set property to get proper url (as you described it in the other topic). However, I quickly made some tests and even with properly obtained pXX I still receive 412 responses. I already changed my client to use `MKCOL` instead, but I just can't stop wondering why `MKCALENDAR` doesn't work as it should – Bartek Małachowski Nov 26 '18 at 23:56
  • That is weird, but if you look at a Charles trace, iCal.app (even on Mojave) is using MKCALENDAR. Of course it could be the case that I'm on an older partition and they are upgrading something on yours. – hnh Nov 27 '18 at 14:34

0 Answers0