WebDAV, editing contacts.

Feb 8 2010 7:32 AM

Hi there,


I'm trying to write a simple program that fetches a users contacts from an Exchange 2003 server, run their number through an address list (i.e. white pages) and saves them again. I managed to fetch the contact info using WebDAV, but when I try to save the info back (using PROPPATCH), I get an 403 error.


I have the following query:
 String url = "https://myserver/exchdav/"; //This is the URL used to fetch the contact info, without problems.

[...]


public string updateContact(Contact c)
{
String query = "<?xml version=\"1.0\"?>"
+ "<a:propertyupdate xmlns:a=\"DAV:\" xmlns:b=\"http://schemas.microsoft.com/exchange/\" xmlns:c=\"urn:schemas:contacts:\" xmlns:mapi=\"http://schemas.microsoft.com/mapi/\">"
+ "<a:set>"
+ "<a:prop>"
+ "<a:contentclass>urn:content-classes:person</a:contentclass>"
+ "<b:outlookmessageclass>IPM.Contact</b:outlookmessageclass>"
+ "<c:homepostaladdress>" + c.address + "</c:homepostaladdress>"
+ "</a:prop>"
+ "</a:set>"
+ "</a:propertyupdate>";

//c.href holds the url directly to the contact, i.e. https://myserver/exchdav/myuser/contacts/mycontact.EML
return this.sendRequest(c.href, query, "PROPPATCH"); ;
}

   The sendRequest method invokes all the credentials and all seems fine. It even returns an "OK 200" response at first, but when i read the responseStream it says 
 https://myserver/exchdav/myuser/Contacts/mycontact.EML
HTTP/1.1 403 Forbidden



I do not necessarily need to use WebDAV, if there's an other easier/better/working way of doing this, please let me know.


Any ideas?
Regards