Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-21-2011, 08:26 AM
Starter Member
 
Posts: 2
Default Updating contacts using REST

I'm trying to update a single contact in my addressbook by specifying the id of the contact and the VCF format (http://localhost/home/user/contacts?...th=nsc&fmt=vcf). The server accepts the contact (no errors), but instead of overwriting the contact it adds a new contact. Has anyone updated a contact successfully before?

It doesnt have to be in VCF format. Any format will do.

The following Java code was used to save a contact:

public void saveItem( int itemID, String vcf ) throws Exception{
String server = "localhost"
URL url = new URL( server + "/home/laukvik/contacts?id=" + itemID + "&auth=nsc&fmt=vcf" );
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.setDoInput( true );
uc.setDoOutput( true );
uc.setRequestMethod("POST");
uc.setRequestProperty ("Authorization", "Basic " + encoding);
uc.setRequestProperty( "Content-Type", "text/x-vcard" );
uc.setRequestProperty( "Content-Length", vcf.length() + "" );
uc.setUseCaches( false );
OutputStream wr = uc.getOutputStream();
wr.write( vcf.getBytes() );
wr.flush();
}
Reply With Quote
  #2 (permalink)  
Old 03-21-2011, 06:11 PM
Outstanding Member
 
Posts: 717
Default

Did you try adding a "&resolve=replace" to the REST URL?
__________________
01 Networks, LLC / Cybernetik.net
Zimbra NE and OSS Cloud Hosting
Shared Web Hosting
Consulting Services
Reply With Quote
  #3 (permalink)  
Old 03-22-2011, 02:05 AM
Starter Member
 
Posts: 2
Default

Thanks for the quick response!

I just tried with the resolve=replace parameter you specified with no luck :-( I can't seem to find that parameter in the documentation I'm using (ZCS 6.0:Zimbra REST API Reference - Zimbra :: Wiki).

Am I looking at the wrong documentation page? Are there more documentation available on updating contacts?

Do the update method require additional http headers not mentioned in the documentation?

All help and pointers appreciated :-)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.