Question

I've been trying to recieve the iCloud contacts related to my Apple Id, but for some reason it doesn't work. I'm getting a (404) Not Found error.

I know iCloud uses CardDAV and that you need a specific URL address in order to access your Contacts.

For the CardDAV client I used the following: https://github.com/Metric/CardDavNet For the server address I tried multiple url's (ofcourse MYUSERID is my real user id):

https://p02-caldav.icloud.com/MYUSERID/carddavhome/card/ https://p02-contacts.icloud.com/MYUSERID/carddavhome/card/

What am I doing wrong? Am I using the correct server URL's or is there something else wrong? I hope someone can guide me into the right direction.

Was it helpful?

Solution

The second URL you mention looks kinda OK. But to reliably get the URL which hosts your address book, you need to query the addressbook-home-set property of the principal record of your account.

Like:

PROPFIND Depth:0 /12345/principal/
<propfind xmlns="DAV:">
  <prop>
    <addressbook-home-set xmlns="urn:ietf:params:xml:ns:carddav"/>
  </prop>
</propfind>

and to find the principal, you query for the 'principal-URL' property, e.g. on /, with your auth set:

PROPFIND Depth:0 /
<propfind xmlns="DAV:">
  <prop><principal-URL/></prop>
</propfind>

You might also want to use a debugging proxy like Charles or Fiddler to figure out what your .NET framework is actually sending to the server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top