CalDav Client for iCloud: MKCOL fails with 412 precondition failed

a 夏天 提交于 2019-12-11 02:47:50

问题


I need help. I implemented a CalDav Client on our System and it worked like a charm. Now I have some problems with creating new calendars on iCloud. Maybe some of you know how I can fix this.

Currently I get a 412 Error.

Headers:

"Depth: 1"
"Content-Type: application/xml; charset=UTF-8"
"User-Agent: DAVKit/4.0.1 (730); CalendarStore/4.0.1 (973); iCal/4.0.1 (1374); Mac OS X/10.6.2 (10C540)"`

Request:

`MKCOL`

Body:

    <D:mkcol xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav"> 
    <D:set>
      <D:prop>
        <D:resourcetype>
          <D:collection/>
          <C:calendar-collection/>
       </D:resourcetype>"
       <D:displayname>some name</D:displayname>
      </D:prop>
    </D:set>
    </D:mkcol>`

URL:

https://caldav.icloud.com/1722222111/calendars/64DA8FE9D95A40E4B83A45B47DEC6C53/

The URL ist my Principle (I changed it of course) and a randomly generated UUID for the calendar resource.

Maybe somebody spots any errors? Used to work fine 6 months ago.

Thank you very much!


回答1:


While there seems to be a mapping bug on the caldav.icloud.com endpoint (filed that as Radar 46258347 if you want to refer), you are not supposed to hit a /calendars URL on this endpoint in the first place.

You only use caldav.icloud.com to discover the principal resource (representing the user/account). This contains the actual partition hosting the caldav server for your account, it looks like:

https://pXX-caldav.icloud.com/asdfjasdjkjfd/calendars/

Those endpoint still seem to work just fine (just tried).

So how do you get from caldav.icloud.com to the actual CalDAV server? You need to retrieve the calendar-home-set property of the principal.

The whole process is described in the CalDAV RFC or in this nice guide: http://sabre.io/dav/building-a-caldav-client/#discovery.




回答2:


If you use https://pXX-caldav.icloud.com/123456789/new-calendar-name-or-href/ for making MKCOL request, then you will get 201 CREATED status and the href of your new collection will be pXX-caldav.icloud.com/123456789/calendars/new-calendar-name-or-href/

so remove calendars/ from your path to create



来源:https://stackoverflow.com/questions/53305100/caldav-client-for-icloud-mkcol-fails-with-412-precondition-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!