Unable to track changers with sync-collection operation of Google CardDAV API

171 Views Asked by At

I'm trying to use the sync-collection operation of Google CardDAV API. It's not well explained in the documentation. But I think following is what they have explained in this documentation.

First, discover the sync-token from address book using propfind operation. Following is my request and I get the sync-token successfully.

Request

Depth: 0
Content-Type: application/xml; charset=utf-8
<d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/">
  <d:prop>
     <d:displayname />
     <cs:getctag />
     <d:sync-token />
  </d:prop>
</d:propfind>

Response

ncoding="UTF-8"?>
<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:ical="http://apple.com/ns/ical/">
    <d:response>
        <d:href>/carddav/v1/principals/[email protected]/lists/default/</d:href>
        <d:propstat>
            <d:status>HTTP/1.1 200 OK</d:status>
            <d:prop>
                <d:displayname>Address Book</d:displayname>
                <d:sync-token>https://www.googleapis.com/carddav/v1/synctoken/SOMEIDINHERE</d:sync-token>
                <cs:getctag>"23fq3fqefas.8"</cs:getctag>
            </d:prop>
        </d:propstat>
    </d:response>
</d:multistatus>

Then we have to do a sync-collection operation with sync-token to get changes from the previous state, but that doesn't return any item, regardless of whatever the change I do in my contact list at https://contacts.google.com/.

Request

<?xml version="1.0" encoding="utf-8" ?>
<d:sync-collection xmlns:d="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
  <d:sync-token>https://www.googleapis.com/carddav/v1/synctoken/SOMEIDINHERE</d:sync-token>
  <d:sync-level>1</d:sync-level>
  <d:prop>
     <d:displayname />
     <d:current-user-principal />
     <d:principal-URL/>
  </d:prop>
</d:sync-collection>

Response

<?xml version="1.0" encoding="UTF-8"?>
<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:ical="http://apple.com/ns/ical/">
    <d:sync-token>https://www.googleapis.com/carddav/v1/synctoken/SOMEIDINHERE </d:sync-token>

</d:multistatus>

Please let me know what am I doing wrong.

1

There are 1 best solutions below

0
Arnaud Quillaud On

In general, the normal mode of operation is to issue a first sync-collection with an empty sync-token (see https://www.rfc-editor.org/rfc/rfc6578#section-3.8 ) and use the sync-token returned in the response in following requests.