开发者

How to get Zimbra's Calendars names using REST API

I want to get the names of all my zimbra calen开发者_如何学Pythondars using a REST request. How to do it ? Thnx


This is not REST but even not Zimbra's SOAP API, but it's a solution :

            URL url = new URL(SOAPUrl);
        URLConnection connection = url.openConnection();
        HttpURLConnection httpConn = (HttpURLConnection) connection;

        String  postContent = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\">"+
        "<soap:Header>" +
        "<context xmlns=\"urn:zimbra\">" +
        "<format type=\"js\"/>" +
        "<authToken>" + authToken + "</authToken>" +
        "</context>" +
        "</soap:Header>" +
        "<soap:Body>" + 
        "<GetFolderRequest xmlns=\"urn:zimbraMail\" />" +
        "</soap:Body>" +
        "</soap:Envelope>";

         // 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...
        String s = null;
        String soapResponse = "";
        while((s=in.readLine()) != null){
            soapResponse += s;
        }
        System.out.println(soapResponse);

And when you parse the result, take the folders that correspond to what you want (Appointment...)


I don't think you can do this with REST. But you can do it using SOAP. Check the following url.

http://mmrblogger.blogspot.in/2013/04/how-to-get-all-calendar-names-for.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜