Results 1 to 6 of 6

Thread: Retrieve TZ settings for a given Timezone using SOAP / REST ?

Hybrid View

  1. #1
    Join Date
    Oct 2009
    Location
    Dublin, IRELAND
    Posts
    712
    Rep Power
    7

    Default Retrieve TZ settings for a given Timezone using SOAP / REST ?

    When I initiate a SOAP session - I can return my default timezone with a GetInfoRequest

    Code:
    "zimbraPrefTimeZoneId": "Europe/London",
    The detailed settings related to the timezone are stored in the timezones.ics file on the zimbra server.

    Code:
    BEGIN:VTIMEZONE
    TZID:Europe/London
    LAST-MODIFIED:20130114T193956Z
    X-ZIMBRA-TZ-PRIMARY:TRUE
    X-ZIMBRA-TZ-MATCH-SCORE:100
    X-ZIMBRA-TZ-ALIAS:(GMT) Dublin / Edinburgh / Lisbon / London
    X-ZIMBRA-TZ-ALIAS:(GMT) Greenwich Mean Time - Dublin / Edinburgh / Lisbon / London
    X-ZIMBRA-TZ-ALIAS:(UTC) Dublin / Edinburgh / Lisbon / London
    X-ZIMBRA-TZ-ALIAS:(UTC) Greenwich Mean Time - Dublin / Edinburgh / Lisbon / London
    X-ZIMBRA-TZ-ALIAS:Europe/Belfast
    X-ZIMBRA-TZ-ALIAS:Europe/Guernsey
    X-ZIMBRA-TZ-ALIAS:Europe/Isle_of_Man
    X-ZIMBRA-TZ-ALIAS:Europe/Jersey
    X-ZIMBRA-TZ-ALIAS:GB
    X-ZIMBRA-TZ-ALIAS:GB-Eire
    BEGIN:STANDARD
    TZNAME:GMT/BST
    DTSTART:19710101T020000
    TZOFFSETTO:+0000
    TZOFFSETFROM:+0100
    RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
    END:STANDARD
    BEGIN:DAYLIGHT
    TZNAME:GMT/BST
    DTSTART:19710101T010000
    TZOFFSETTO:+0100
    TZOFFSETFROM:+0000
    RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=-1SU
    END:DAYLIGHT
    END:VTIMEZONE
    Is there any way to retrieve this timezone data through the SOAP or REST APIs ?

  2. #2
    Join Date
    Aug 2010
    Location
    England
    Posts
    39
    Rep Power
    5

    Default

    I don't believe this is possible through the SOAP or REST APIs. However, you can use a CalDAV PROPFIND request to get this information (you would need to authenticate using HTTP headers):

    Here is an example:

    Code:
    PROPFIND https://mail.zimbra.com/dav/nonexistent@zimbra.com/Calendar HTTP/1.1
    Authorization: *** REPLACED ***
    Content-Type: text/xml
    
    <?xml version="1.0" encoding="utf-8"?>
    <x0:propfind xmlns:x1="urn:ietf:params:xml:ns:caldav" xmlns:x0="DAV:" xmlns:x2="http://calendarserver.org/ns/">
     <x0:prop>
      <x1:calendar-timezone/>
     </x0:prop>
    </x0:propfind>
    should yield a response similar to:

    Code:
    HTTP/1.1 207 Multi-Status
    status:207
    transfer-encoding:chunked
    connection:keep-alive
    server:nginx
    dav:1, 2, 3, access-control, calendar-access, calendar-schedule, version-control, addressbook, extended-mkcol, calendar-proxy, calendarserver-principal-property-search
    date:Tue, 05 Nov 2013 12:26:50 GMT
    content-type:text/xml;charset=UTF-8
    
    <?xml version="1.0" encoding="UTF-8"?>
    
    <D:multistatus xmlns:D="DAV:">
      <D:response>
        <D:href>/dav/nonexistent@zimbra.com/Calendar/</D:href>
        <D:propstat>
          <D:status>HTTP/1.1 200 OK</D:status>
          <D:prop>
            <C:calendar-timezone xmlns:C="urn:ietf:params:xml:ns:caldav"><![CDATA[BEGIN:VTIMEZONE
    TZID:Europe/London
    BEGIN:STANDARD
    DTSTART:16010101T020000
    TZOFFSETTO:-0000
    TZOFFSETFROM:+0100
    RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
    TZNAME:GMT/BST
    END:STANDARD
    BEGIN:DAYLIGHT
    DTSTART:16010101T010000
    TZOFFSETTO:+0100
    TZOFFSETFROM:-0000
    RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=-1SU
    TZNAME:GMT/BST
    END:DAYLIGHT
    END:VTIMEZONE
    ]]></C:calendar-timezone>
          </D:prop>
        </D:propstat>
      </D:response>
    </D:multistatus>
    Hope this helps.
    Regards,
    Gren

  3. #3
    Join Date
    Oct 2009
    Location
    Dublin, IRELAND
    Posts
    712
    Rep Power
    7

    Default

    Thanks for the reply. I will have to see if I can figure out how to call this through CURL.

    Where do I send the request to ? For your example - does the request get sent to

    https://mail.zimbra.com

    or is it sent to

    https://mail.zimbra.com/dav/nonexist...a.com/Calendar

    Thanks again.

  4. #4
    Join Date
    Aug 2010
    Location
    England
    Posts
    39
    Rep Power
    5

    Default

    Quote Originally Posted by liverpoolfcfan View Post
    Thanks for the reply. I will have to see if I can figure out how to call this through CURL.

    Where do I send the request to ? For your example - does the request get sent to

    https://mail.zimbra.com

    or is it sent to

    https://mail.zimbra.com/dav/nonexist...a.com/Calendar

    Thanks again.
    If you have a file called propfind-calendar-timezone.xml with this content:

    Code:
    <x0:propfind xmlns:x1="urn:ietf:params:xml:ns:caldav" xmlns:x0="DAV:">
     <x0:prop>
      <x1:calendar-timezone/>
     </x0:prop>
    </x0:propfind>
    then something similar to this curl command should do the trick:

    Code:
    curl -v --request PROPFIND --user nonexistent@zimbra.com:myCleverPassword --header content-type:text/xml --data-binary @propfind-calendar-timezone.xml https://mail.zimbra.com/dav/nonexistent@zimbra.com/Calendar

  5. #5
    Join Date
    Aug 2010
    Location
    England
    Posts
    39
    Rep Power
    5

    Default curl command to retrieve default VTIMEZONE for the default calendar

    Hi,

    You need send the request to the longer URL.
    This is one way to do it with curl. Create a file called propfind-calendar-timezone.xml with this contents:

    Code:
    <x0:propfind xmlns:x1="urn:ietf:params:xml:ns:caldav" xmlns:x0="DAV:">
     <x0:prop>
      <x1:calendar-timezone/>
     </x0:prop>
    </x0:propfind>
    and issue a command similar to:

    Code:
    curl -v --request PROPFIND --user nonexistent@zimbra.com:password --header content-type:text/xml --data-binary @propfind-calendar-timezone.xml https://mail.zimbra.com/dav/nonexistent@zimbra.com/Calendar
    All the best,
    Gren.

  6. #6
    Join Date
    Oct 2009
    Location
    Dublin, IRELAND
    Posts
    712
    Rep Power
    7

    Default

    Thanks for that.

    In case anyone else is interested in fetching this data from PHP here is how to do it.

    Code:
            $propfind = '<x0:propfind xmlns:x1="urn:ietf:params:xml:ns:caldav" xmlns:x0="DAV:">
                          <x0:prop>
                           <x1:calendar-timezone/>
                          </x0:prop>
                         </x0:propfind>';
    
    
            $ch = curl_init();
            $url = $zimbraPublicURL . "/dav/" . $zimbraAccountName . "/Calendar";
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); 
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_HEADER, 0); 
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('content-type:text/xml')); 
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $propfind); 
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PROPFIND "   );
            curl_setopt($ch, CURLOPT_COOKIE, 'ZM_AUTH_TOKEN=' . $zimbraAuthtoken);
            $tzInfo = curl_exec($ch);
    
            curl_close($ch);
    where zimbraPublicURL is the public URL of the zimbra server returned from a GetInfoRequest, zimbraAccountName is the account name returned from a GetInfoRequest, and the zimbraAuthtoken is an auth token as returned from an AuthRequest

    The response looks like
    Code:
    PROPFIND: <?xml version="1.0" encoding="UTF-8"?>
    
    <D:multistatus xmlns:D="DAV:">
      <D:response>
        <D:href>/dav/zimbraAccountName/Calendar/</D:href>
        <D:propstat>
          <D:status>HTTP/1.1 200 OK</D:status>
          <D:prop>
            <C:calendar-timezone xmlns:C="urn:ietf:params:xml:ns:caldav"><![CDATA[BEGIN:VTIMEZONE
    TZID:Europe/London
    BEGIN:STANDARD
    DTSTART:19710101T020000
    TZOFFSETTO:-0000
    TZOFFSETFROM:+0100
    RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
    TZNAME:GMT/BST
    END:STANDARD
    BEGIN:DAYLIGHT
    DTSTART:19710101T010000
    TZOFFSETTO:+0100
    TZOFFSETFROM:-0000
    RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=-1SU
    TZNAME:GMT/BST
    END:DAYLIGHT
    END:VTIMEZONE
    ]]></C:calendar-timezone>
          </D:prop>
        </D:propstat>
      </D:response>
    </D:multistatus>

Similar Threads

  1. Using SOAP API to retrieve message headers
    By chrson in forum Developers
    Replies: 1
    Last Post: 04-22-2013, 11:43 AM
  2. SOAP - Get TimeZone Info
    By gnosbush in forum Developers
    Replies: 0
    Last Post: 06-02-2010, 03:18 PM
  3. Zimbra Timezone settings
    By athrasher@dps.k12.il.us in forum Administrators
    Replies: 0
    Last Post: 03-02-2010, 05:55 AM
  4. retrieve contacts in SOAP/XML not JSON
    By zimbrero in forum Developers
    Replies: 1
    Last Post: 03-21-2009, 01:44 AM
  5. Retrieve e-mail messages via soap
    By kuip in forum Developers
    Replies: 2
    Last Post: 07-23-2007, 01:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •