views:

17

answers:

1

I have been using WebDAV in PHP directly using XML. I have managed to create emails with attachments and so forth, but when i try to create a contact, I keep getting "400 Bad Request". Here is the webdav query and how i'm executing it:

 <?xml version="1.0"?>
    <g:propertyupdate 
    xmlns:g="DAV:" 
    xmlns:c="urn:schemas:contacts:" 
    xmlns:e="http://schemas.microsoft.com/exchange/" 
    xmlns:mapi="http://schemas.microsoft.com/mapi/" 
    xmlns:x="xml:" 
    xmlns:cal="urn:schemas:calendar:" 
    xmlns:mail="urn:schemas:httpmail:">
    <g:set>
    <g:prop>
    <g:contentclass>urn:content-classes:person</g:contentclass>
    <e:outlookmessageclass>IPM.Contact</e:outlookmessageclass>
    <c:givenName>JoLynn</c:givenName>
    <c:middlename>Julie</c:middlename>
    </g:prop>
    </g:set>
    </g:propertyupdate>

And response:

HTTP/1.1 400 Bad Request
Connection: close
Date: Mon, 05 Jul 2010 08:41:43 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Content-Type: text/html
Content-Length: 1709
MS-WebStorage: 6.5.7638

And sending the data: $h->fetch($url, 0, null, $exchange_username, $exchange_password, "PROPPATCH")

Any help greatly appreciated!¬

I started with Troy Wolf's example code at http://www.troywolf.com/articles/php/exchange_webdav_examples.php

A: 

Ah i fixed it, forgot to send some headers with the request (content-type, depth and translate headers to be precise!)

Chris