Netxcloud/Carddav Sync Using ApacheJackRabbit


  • hi,

    I’m trying to run basic steps to optimize my sever contacts synchronization with nextcloud contacts’s cardav using SabreDav Specification like this one :
    http://sabre.io/dav/building-a-carddav-client/
    The most suitable one is to get the nextcloud Ctag and comapre it with your server Ctag using a PROPFIND method to get the Ctag and the sysnc token

    FULL REQUEST :

       PROPFIND /addressbooks/johndoe/contacts/ HTTP/1.1
           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>
    

    the response will be like this :

        ```<d:multistatus xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/">
    <d:response>
        <d:href>/addressbooks/johndoe/contacts/</d:href>
        <d:propstat>
            <d:prop>
                <d:displayname>My Address Book</d:displayname>
                <cs:getctag>3145</cs:getctag>
                <d:sync-token>http://sabredav.org/ns/sync-token/3145</d:sync-token>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response></d:multistatus>
    

    But when i try the “WebDAV-Sync” fearture by the sync token from this request :

    REPORT /addressbooks/johndoe/contacts/ HTTP/1.1
    Host: dav.example.org
    Content-Type: application/xml; charset="utf-8"
    
    <?xml version="1.0" encoding="utf-8" ?>
    <d:sync-collection xmlns:d="DAV:">
    <d:sync-token>http://sabredav.org/ns/sync/   SYNC-TOKEN  </d:sync-token>
    <d:sync-level>1</d:sync-level>
    <d:prop>
     <d:getetag/>
    </d:prop>
    </d:sync-collection>
    

    I get this response indicating that i have the wrong token

    <?xml version="1.0" encoding="utf-8"?>
    <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
    <s:exception>Sabre\DAV\Exception\InvalidSyncToken</s:exception>
    <s:message>Invalid or unknown sync token</s:message>
    <d:valid-sync-token/>
    </d:error>
    
    

    This step helps us optimize synchronization time and data as it return only the changed contacts, but the nextcloud server doesn’t recognize token despite that it implements SabreDav and it return a sync token.

    I hope that someone can help me as it 's the firest time that i write in this forum.


  • I get it done by changing the SYNCTOKEN_PREFIX form the SabreDav Doc to the nextcloud one according this link :
    https://github.com/nextcloud/3rdparty/blob/master/sabre/dav/lib/DAV/Sync/Plugin.php

     http://sabredav.org/ns/sync/   SYNC-TOKEN     =>     http://sabre.io/ns/sync/   SYNC-TOKEN
    

    Hope it helps.

Similar topics