Results 1 to 7 of 7

Thread: [SOLVED] REST -ful way to list calendars?

  1. #1
    Join Date
    Mar 2007
    Posts
    5
    Rep Power
    8

    Default [SOLVED] REST -ful way to list calendars?

    I'd like to build an app for our Zimbra users to add individual events from some non-Zimbra public calendars to their Zimbra calendars.

    Using the migration guide, I can see how to use curl to upload an event to a user's calendar (given their username/password, which the app will have access to).

    But the question now is *which* calendar to add the event too?

    Another thread indicates that an administrator can do this sort of thing...
    zmmailbox -z -m <account> gaf

    Is there a REST -ful way to get such a list of calendars?

  2. #2
    Join Date
    Mar 2009
    Posts
    10
    Rep Power
    6

    Default

    I don't think this is exactly what you're asking for, but here's a good example of a REST url for a "non-standard" calendar that we use (shared company calendar). This one was to deliver the ICS version of said calendar to another application.

    https://mail.ourcompany.com/service/...lendar?fmt=ics

    So, in this sample, the calendar's name in Zimbra was shown as:

    "Our Company Calendar" which is given in the REST url as "our%20company%20calendar" (without quotes, of course).

    This works bi-directionally for adding, removing and changing events from another application for a specific calendar in Zimbra, so I thought it might point you in the right direction. Hope this helps!

  3. #3
    Join Date
    Mar 2007
    Posts
    5
    Rep Power
    8

    Default

    This is good stuff. But what I still need is a REST-ful way to find out what all the possible calendar names are.

  4. #4
    Join Date
    Dec 2009
    Posts
    14
    Rep Power
    5

    Default

    Hi paumr, did you ever find a way of doing this? I'm trying to do the same thing. Any help much appreciated!

  5. #5
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    5

    Default

    You can use the <GetFolderRequest> SOAP command and that will return a list of folders. The folders with view="appointment" are calendar folders.

    Submit the <GetFolderRequest xmlns="urn:zimbraMail" /> request and get the response and parse the response for view="appointment" for calendar folders.

    Code:
    <GetFolderResponse xmlns="urn:zimbraMail">
    <folder>........</folder>
    <folder>........</folder>
    <folder view="appointment" i4ms="307" ms="307" i4next="587" l="1" id="586" rev="307" color="1" f="#" n="0" name="myholidaycalendar" rgb="#9EB6F5" s="0"/>
    <folder i4ms="306" view="appointment" ms="1" f="#" i4next="585" n="15" l="1" name="Calendar" s="0" id="10" rev="1"/>
    <folder>........</folder>
    <folder>........</folder>
    <folder>........</folder>
    </GetFolderResponse>
    Now your next question is: I don't want to have to call SOAP, can I do this without SOAP? Yes.

    You can just submit the SOAP formatted XML to the server SOAP URL. And read the XML response. That does not require SOAP or a SOAP library, so you can call it from anywhere.

    For example, to do this thru Java, you can make a URL connection to the SOAP URL, post the XML content and read the response. The follow shows submitting SOAP XML to a URL without the use of a SOAP toolkit or any Zimbra-specific SOAP Java libraries...it's just plain-ol' Java:

    Code:
    String SOAPUrl      = "http://localhost:7070/service/soap/";
    
    // Create the connection where we're going to send the file.
    URL url = new URL(SOAPUrl);
    URLConnection connection = url.openConnection();
    HttpURLConnection httpConn = (HttpURLConnection) connection;
    
    String	postContent = "<soap>....</soap>"; // insert your SOAP XML!!!
    byte[] b = postContent.getBytes();
    
    // Set the appropriate HTTP parameters.
    httpConn.setRequestProperty( "Content-Length", String.valueOf( b.length ) );
    httpConn.setRequestProperty("Content-Type","application/soap+xml; charset=utf-8");
    httpConn.setRequestMethod( "POST" );
    httpConn.setDoOutput(true);
    httpConn.setDoInput(true);
    
    // Everything's set up; send the XML that was read in to b.
    OutputStream out = httpConn.getOutputStream();
    out.write( b );    
    out.close();
    
    // Read the response and write it to standard out.
    InputStreamReader isr = new InputStreamReader(httpConn.getInputStream());
    BufferedReader in = new BufferedReader(isr);
    
    // read & do something with input stream...
    
    in.close();
    Now what does a SOAP XML format look like? Here's a sample of making the <GetFolderRequest>. Be sure to replace the auth token with your auth token (from the ZM_AUTH_TOKEN cookie...or use the <AuthRequest> SOAP command to generate an auth token:

    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header>
    <context xmlns="urn:zimbra">
    <format xmlns="" type="xml"/>
    <authToken xmlns="">XXX_XXXX_XXXX</authToken>
    </context>
    </soap:Header>
    <soap:Body>
    <GetFolderRequest xmlns="urn:zimbraMail" />
    </soap:Body>
    </soap>
    So it's not "REST" per se but it's a way of calling into Zimbra via URL and no external libraries required. You submit content to a URL and read a response. That's about it.

    Note: you can do the same thing and submit JSON (instead of XML) and get a JSON response (instead of XML) if that format works better for you. See ZimbraServer/docs/soap.txt for more information on these commands and the SOAP API in general.

    Also, if you want to test-out the SOAP commands, you can use the ZmSoap utility that is part of ZCS.

    Zmsoap - Zimbra :: Wiki

  6. #6
    Join Date
    Mar 2007
    Posts
    5
    Rep Power
    8

    Default

    No, I never did find out how to query all calendar names via REST.

    Our organization gives each user a calendar called "calendar", so I had my app add the event to that one, because I know it must exist.

    But it would still be nice to be able to allow users to add events to calendars that they've set up themselves.

  7. #7
    Join Date
    Mar 2007
    Posts
    5
    Rep Power
    8

    Default

    Sposetti,

    Cool! Yes, that's exactly the sort of thing I was hoping to do. And yes, I wanted a non-SOAP way of doing it :->

Similar Threads

  1. [SOLVED] Sudden problem synching with gmail
    By bouchardpie in forum Error Reports
    Replies: 8
    Last Post: 09-09-2010, 09:50 AM
  2. Exchange/Imap errors
    By pmibal in forum General Questions
    Replies: 4
    Last Post: 09-23-2009, 11:46 AM
  3. Error using Zimbra Desktop with all folders
    By randhirv in forum Error Reports
    Replies: 3
    Last Post: 01-24-2009, 12:01 AM
  4. Problem syncing all folders
    By mark_the_chain in forum Error Reports
    Replies: 0
    Last Post: 11-23-2008, 03:59 PM
  5. Display 2 calendars with REST Url
    By marinew in forum Users
    Replies: 0
    Last Post: 07-08-2008, 10:45 AM

Posting Permissions

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