0

I try to get all contacts from an iCloud Account...

First I run:

<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:">
    <d:prop>
        <d:current-user-principal/>
    </d:prop>
</d:propfind>

Then I get /xxxxxxxxxxx/carddavhome/ and run:

<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
    <d:prop>
        <card:addressbook-home-set/>
    </d:prop>
</d:propfind>

This give me the URL https://pXX-contacts.icloud.com:443/xxxxxxxxxxx/carddavhome/ then I send the following request to this URL:

<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
    <d:prop>
        <d:displayname/>
        <d:resourcetype/>
    </d:prop>
</d:propfind>

And I get:

<?xml version="1.0" encoding="UTF-8"?>
<multistatus xmlns="DAV:">
    <response>
        <href>/xxxxxxxxxxx/carddavhome/</href>
        <propstat>
            <prop>
                <resourcetype>
                    <collection/>
                </resourcetype>
            </prop>
            <status>HTTP/1.1 200 OK</status>
        </propstat>

        <propstat>
            <prop>
                <displayname/>
            </prop>
            <status>HTTP/1.1 404 Not Found</status>
        </propstat>
    </response>
</multistatus>

If I try to run this to the the URL https://pXX-contacts.icloud.com:443/xxxxxxxxxxx/carddavhome/contacts

<?xml version="1.0" encoding="UTF-8"?>
<card:addressbook-query xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
    <d:prop>
        <d:getetag/>
        <card:address-data/>
    </d:prop>
</card:addressbook-query>

I get: Improperly formed XML encountered, unexpected root node

What is my mistake? The first 2 queries work and give me the expected results, the 3rd one should give me a list of the addressbooks and groups and the 4th one should give me all VCards.

1 Answers1

0

For the first issue, you did not provide the whole HTTP request but I suspect that you are missing a Depth header with a value of 1:

Depth: 1

For the second issue, there does not seem to be anything wrong with your xml payload. Your url on the other hand seems incorrect as it is at least missing the ending slash that denotes a collection (some *DAV servers are more strict about it). Hopefully, solving the first issue will allow you to use the right url when doing the address-book query.

Arnaud Quillaud
  • 4,420
  • 1
  • 12
  • 8