I am trying to download contacts from Zimbra using the following code :
public static void getHTTPFile() {
HttpClient client = new HttpClient();
List<String> authPrefs = new ArrayList<String>(2);
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
client.getState().setCredentials(
new AuthScope(HOST, new Integer(PORT).intValue(), AuthScope.ANY_REALM),
new UsernamePasswordCredentials(NAME, PASSWORD)
);
GetMethod get = new GetMethod("http://"+HOST+":"+PORT+"/home/"+USER+"/contacts?fmt=csv");
get.setDoAuthentication(true);
try {
int status = client.executeMethod(get);
System.out.println(status + "\n" + get.getResponseBodyAsString());
} catch (IOException e) {
e.printStackTrace();
} finally {
get.releaseConnection();
}
}
But I obtain an error 404 (Not Found) :
13 juin 2012 08:40:47 org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: Basic authentication scheme selected
404
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 no such item</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /service/home/USER/contacts. Reason:
<pre> no such item</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
Is my URL wrong? Regarding the documentation it seems not.
Is there a problem with the authentification? I don't obtain an error 401 (Unauthorized).
Any idea?
Thanks for your help.
EDIT:
Is there a limitation of Zimbra on the server side? Like for example we can only access to it through a web browser or a smartphone.