title: Manipulate groups in iCloud with CardDAV protocol
body: <p>I am currently trying to manipulate groups of my contact list in iCloud through CardDav protocol.
  For that, I created a group containing a contact in Contact.app:
  <a href="http://postimg.org/image/x1kqojbwz/" rel="nofollow">Screenshot</a></p>
  
  <p>When I export the vCard of my contact directly from Contact app, I have the groups associated with my contacts in the CATEGORIES property :</p>
  
  <pre><code>BEGIN:VCARD
  VERSION:3.0
  PRODID:-//Apple Inc.//Mac OS X 10.9.2//EN
  N:Lebron;Candide;;;
  FN:Candide Lebron
  ORG:Podbox;
  NOTE:Un petit peu candide.
  CATEGORIES:GroupForAutomaticTestDELTA
  UID:d4c1baf6-f603-4fb5-8f19-d45eb1e7fb23
  X-ABUID:D4C1BAF6-F603-4FB5-8F19-D45EB1E7FB23:ABPerson
  END:VCARD
  </code></pre>
  
  <p>However when I request my iCloud server to retrieve this contact I do not get CATEGORIES property set but I retrieve two vCards, one for the contact and one for the group. The group vCard contains references to its members.</p>
  
  <p>Request:</p>
  
  <pre><code>curl --request REPORT  --user ****@*****:**** --header "Content-Type: text/xml" --data '
      &lt;?xml version="1.0" encoding="utf-8" ?&gt;
          &lt;C:addressbook-query xmlns:D="DAV:"
                   xmlns:C="urn:ietf:params:xml:ns:carddav"&gt;
   &lt;D:prop&gt;
     &lt;C:address-data/&gt;
   &lt;/D:prop&gt;
   &lt;/C:addressbook-query&gt;' https://contacts.icloud.com/802592377/carddavhome/card/
  </code></pre>
  
  <p>contact VCard:</p>
  
  <pre><code>BEGIN:VCARD&amp;#13;
  VERSION:3.0&amp;#13;
  PRODID:-//Apple Inc.//Mac OS X 10.9.2//EN&amp;#13;
  N:Lebron;Candide;;;&amp;#13;
  FN:Candide Lebron&amp;#13;
  ORG:Podbox;&amp;#13;
  NOTE:Un petit peu candide.&amp;#13;
  REV:2014-06-12T16:53:51Z&amp;#13;
  UID:d4c1baf6-f603-4fb5-8f19-d45eb1e7fb23&amp;#13;
  END:VCARD&amp;#13;
  </code></pre>
  
  <p>group vCard:</p>
  
  <pre><code>BEGIN:VCARD
  VERSION:3.0
  PRODID:-//Apple Inc.//AddressBook 8.0//EN
  N:GroupToBeAddedTO
  FN:GroupToBeAddedTO
  X-ADDRESSBOOKSERVER-KIND:group
  X-ADDRESSBOOKSERVER-MEMBER:urn:uuid:d4c1baf6-f603-4fb5-8f19-d45eb1e7fb23
  REV:2014-06-12T16:43:04Z
  UID:d59c9f0c-27aa-47e3-96e7-43717bbc1d7e
  END:VCARD
  </code></pre>
  
  <p>Notice the CATEGORIES property appearing in contact export but not with a CardDAV request. My guess would be that the Contact app constructs the CATEGORIES when exporting but I am not sure.</p>
  
  <p>Do someone has an idea of how iCloud works exactly? Am I missing something preventing me to retrieve CATEGORIES through CardDAV?</p>