如何使用REST API获取Zimbra的日历名称

时间:2011-06-22 13:49:29

标签: rest zimbra

我想使用REST请求获取所有zimbra日历的名称。 怎么做 ? 日Thnx

2 个答案:

答案 0 :(得分:1)

这不是REST,但即使不是Zimbra的SOAP API,但它是一个解决方案:

            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);

当您解析结果时,请选择与您想要的对应的文件夹(约会...)

答案 1 :(得分:0)

我认为你不能用REST做到这一点。但是你可以使用SOAP来做到这一点。请检查以下网址。

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