Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Exchange
2000.active.directory
2000.admin
2000.announcements
2000.app.conversion
2000.applications
2000.clients
2000.clustering
2000.connectivity
2000.development
2000.documentation
2000.general
2000.information.store
2000.interop
2000.kms
2000.misc
2000.protocols
2000.realtime.collabo.
2000.setup
2000.transport
2000.win2000
admin
application.conversion
applications
clients
clustering
connectivity
design
development
misc
mobility
setup
tools
  
 
date: Thu, 6 Dec 2007 09:00:02 -0800,    group: microsoft.public.exchange2000.development        back       


Problem creating Contacts in a Public Folder   
I'm trying to import contact information from a database into a Public Folder 
Contactlist using PROPPATCH, however I keep getting the error "Bad Request" 
regardless of how much or little information I put in the XML.

I've pasted the short code for trying to create a new contact in the public 
folder "test" below. Any help would be greatly appreciated.

' Declare the variables that you will use.
Dim objRequest
Dim strBody As String
Dim strURL As String

' Specify the URL of the new object that you will create.
strURL = "http://texas/public/test/"
' Create an HTTP request object.
objRequest = CreateObject("MSXML2.ServerXMLHTTP")

strBody = "<?xml version=""1.0""?>" & _
"<g:propertyupdate xmlns:g=""DAV:"" xmlns:c=""urn:schemas:contacts:"" 
xmlns:e=""http://schemas.microsoft.com/exchange/"">" & _
"<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>" & _
"<c:sn>Dobney</c:sn>" & _
"<c:cn>JoLynn J. Dobney</c:cn>" & _
"<c:fileas>Dobney, JoLynn</c:fileas>" & _
"</g:prop>" & _
"</g:set>" & _
"</g:propertyupdate>"

' Open the request object and assign the PROPPATCH method to it.
objRequest.open("PROPPATCH", strURL, False, username, password)
' Set the required headers for the request.
objRequest.setRequestHeader("Content-Type", "text/xml")
objRequest.setRequestHeader("Translate", "F")
objRequest.setRequestHeader("Content-Length", Len(strBody))

' Send the request. Use the XML document as the body.
Try
   objRequest.send(strBody)

   'Display the results.
   If (objRequest.Status >= 200 And objRequest.Status < 300) Then
      MsgBox("Success!   " & "Results = " & objRequest.Status & _
      ": " & objRequest.statusText)
   ElseIf objRequest.Status = 401 Then
      MsgBox("You do not have permission to do the job. " & _
      "Please check your permissions on this item.")
   Else
      MsgBox("Request Failed.  Results = " & objRequest.Status & _
      ": " & objRequest.statusText)
   End If
Catch ex As Exception
   MsgBox(ex.Message)
End Try
objRequest = Nothing
date: Thu, 6 Dec 2007 09:00:02 -0800   author:   jens

Re: Problem creating Contacts in a Public Folder   
"jens"  wrote in message 
news:054639B8-597B-4044-B469-A42EF6C55C6A@microsoft.com...
> I'm trying to import contact information from a database into a Public 
> Folder
> Contactlist using PROPPATCH, however I keep getting the error "Bad 
> Request"
> regardless of how much or little information I put in the XML.
>
> I've pasted the short code for trying to create a new contact in the 
> public
> folder "test" below. Any help would be greatly appreciated.
>
> ' Declare the variables that you will use.
> Dim objRequest
> Dim strBody As String
> Dim strURL As String
>
> ' Specify the URL of the new object that you will create.
> strURL = "http://texas/public/test/"
> ' Create an HTTP request object.
> objRequest = CreateObject("MSXML2.ServerXMLHTTP")
>
> strBody = "<?xml version=""1.0""?>" & _
> "<g:propertyupdate xmlns:g=""DAV:"" xmlns:c=""urn:schemas:contacts:""
> xmlns:e=""http://schemas.microsoft.com/exchange/"">" & _
> "<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>" & _
> "<c:sn>Dobney</c:sn>" & _
> "<c:cn>JoLynn J. Dobney</c:cn>" & _
> "<c:fileas>Dobney, JoLynn</c:fileas>" & _
> "</g:prop>" & _
> "</g:set>" & _
> "</g:propertyupdate>"
>
> ' Open the request object and assign the PROPPATCH method to it.
> objRequest.open("PROPPATCH", strURL, False, username, password)
> ' Set the required headers for the request.
> objRequest.setRequestHeader("Content-Type", "text/xml")
> objRequest.setRequestHeader("Translate", "F")
> objRequest.setRequestHeader("Content-Length", Len(strBody))
>
> ' Send the request. Use the XML document as the body.
> Try
>   objRequest.send(strBody)
>
>   'Display the results.
>   If (objRequest.Status >= 200 And objRequest.Status < 300) Then
>      MsgBox("Success!   " & "Results = " & objRequest.Status & _
>      ": " & objRequest.statusText)
>   ElseIf objRequest.Status = 401 Then
>      MsgBox("You do not have permission to do the job. " & _
>      "Please check your permissions on this item.")
>   Else
>      MsgBox("Request Failed.  Results = " & objRequest.Status & _
>      ": " & objRequest.statusText)
>   End If
> Catch ex As Exception
>   MsgBox(ex.Message)
> End Try
> objRequest = Nothing

The destination URL can't be just the folder, you will need to provide a 
new, unique URL if you want to create an item.  E.g.

strURL = "http://texas/public/test/whatever-20071207-1347-85962.eml"

Lee.

-- 
______________________________________

Outlook Web Access For PDA , OWA For WAP
www.leederbyshire.com
email a@t leederbyshire d.0.t c.0.m
______________________________________
date: Fri, 7 Dec 2007 13:48:43 -0000   author:   Lee Derbyshire [MVP] email a@t leederbyshire d.0.t c.0.m

Re: Problem creating Contacts in a Public Folder   
Hi Lee, 

Thanks for the response, but even if I add some unique .eml extension to the 
URL I get a bad request error. It's quite frustrating since everything looks 
to be correct.

"Lee Derbyshire [MVP]" wrote:

> "jens"  wrote in message 
> news:054639B8-597B-4044-B469-A42EF6C55C6A@microsoft.com...
> > I'm trying to import contact information from a database into a Public 
> > Folder
> > Contactlist using PROPPATCH, however I keep getting the error "Bad 
> > Request"
> > regardless of how much or little information I put in the XML.
> >
> > I've pasted the short code for trying to create a new contact in the 
> > public
> > folder "test" below. Any help would be greatly appreciated.
> >
> > ' Declare the variables that you will use.
> > Dim objRequest
> > Dim strBody As String
> > Dim strURL As String
> >
> > ' Specify the URL of the new object that you will create.
> > strURL = "http://texas/public/test/"
> > ' Create an HTTP request object.
> > objRequest = CreateObject("MSXML2.ServerXMLHTTP")
> >
> > strBody = "<?xml version=""1.0""?>" & _
> > "<g:propertyupdate xmlns:g=""DAV:"" xmlns:c=""urn:schemas:contacts:""
> > xmlns:e=""http://schemas.microsoft.com/exchange/"">" & _
> > "<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>" & _
> > "<c:sn>Dobney</c:sn>" & _
> > "<c:cn>JoLynn J. Dobney</c:cn>" & _
> > "<c:fileas>Dobney, JoLynn</c:fileas>" & _
> > "</g:prop>" & _
> > "</g:set>" & _
> > "</g:propertyupdate>"
> >
> > ' Open the request object and assign the PROPPATCH method to it.
> > objRequest.open("PROPPATCH", strURL, False, username, password)
> > ' Set the required headers for the request.
> > objRequest.setRequestHeader("Content-Type", "text/xml")
> > objRequest.setRequestHeader("Translate", "F")
> > objRequest.setRequestHeader("Content-Length", Len(strBody))
> >
> > ' Send the request. Use the XML document as the body.
> > Try
> >   objRequest.send(strBody)
> >
> >   'Display the results.
> >   If (objRequest.Status >= 200 And objRequest.Status < 300) Then
> >      MsgBox("Success!   " & "Results = " & objRequest.Status & _
> >      ": " & objRequest.statusText)
> >   ElseIf objRequest.Status = 401 Then
> >      MsgBox("You do not have permission to do the job. " & _
> >      "Please check your permissions on this item.")
> >   Else
> >      MsgBox("Request Failed.  Results = " & objRequest.Status & _
> >      ": " & objRequest.statusText)
> >   End If
> > Catch ex As Exception
> >   MsgBox(ex.Message)
> > End Try
> > objRequest = Nothing
> 
> The destination URL can't be just the folder, you will need to provide a 
> new, unique URL if you want to create an item.  E.g.
> 
> strURL = "http://texas/public/test/whatever-20071207-1347-85962.eml"
> 
> Lee.
> 
> -- 
> ______________________________________
> 
> Outlook Web Access For PDA , OWA For WAP
> www.leederbyshire.com
> email a@t leederbyshire d.0.t c.0.m
> ______________________________________
> 
> 
>
date: Fri, 7 Dec 2007 11:15:01 -0800   author:   jens

Re: Problem creating Contacts in a Public Folder   
Next, I would try removing the contact properties from the code one at a 
time to see if you can isolate the one that is causing the problem.

"jens"  wrote in message 
news:D2B6531B-B56A-481C-8ADF-10E71A3E569E@microsoft.com...
> Hi Lee,
>
> Thanks for the response, but even if I add some unique .eml extension to 
> the
> URL I get a bad request error. It's quite frustrating since everything 
> looks
> to be correct.
>
> "Lee Derbyshire [MVP]" wrote:
>
>> "jens"  wrote in message
>> news:054639B8-597B-4044-B469-A42EF6C55C6A@microsoft.com...
>> > I'm trying to import contact information from a database into a Public
>> > Folder
>> > Contactlist using PROPPATCH, however I keep getting the error "Bad
>> > Request"
>> > regardless of how much or little information I put in the XML.
>> >
>> > I've pasted the short code for trying to create a new contact in the
>> > public
>> > folder "test" below. Any help would be greatly appreciated.
>> >
>> > ' Declare the variables that you will use.
>> > Dim objRequest
>> > Dim strBody As String
>> > Dim strURL As String
>> >
>> > ' Specify the URL of the new object that you will create.
>> > strURL = "http://texas/public/test/"
>> > ' Create an HTTP request object.
>> > objRequest = CreateObject("MSXML2.ServerXMLHTTP")
>> >
>> > strBody = "<?xml version=""1.0""?>" & _
>> > "<g:propertyupdate xmlns:g=""DAV:"" xmlns:c=""urn:schemas:contacts:""
>> > xmlns:e=""http://schemas.microsoft.com/exchange/"">" & _
>> > "<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>" & _
>> > "<c:sn>Dobney</c:sn>" & _
>> > "<c:cn>JoLynn J. Dobney</c:cn>" & _
>> > "<c:fileas>Dobney, JoLynn</c:fileas>" & _
>> > "</g:prop>" & _
>> > "</g:set>" & _
>> > "</g:propertyupdate>"
>> >
>> > ' Open the request object and assign the PROPPATCH method to it.
>> > objRequest.open("PROPPATCH", strURL, False, username, password)
>> > ' Set the required headers for the request.
>> > objRequest.setRequestHeader("Content-Type", "text/xml")
>> > objRequest.setRequestHeader("Translate", "F")
>> > objRequest.setRequestHeader("Content-Length", Len(strBody))
>> >
>> > ' Send the request. Use the XML document as the body.
>> > Try
>> >   objRequest.send(strBody)
>> >
>> >   'Display the results.
>> >   If (objRequest.Status >= 200 And objRequest.Status < 300) Then
>> >      MsgBox("Success!   " & "Results = " & objRequest.Status & _
>> >      ": " & objRequest.statusText)
>> >   ElseIf objRequest.Status = 401 Then
>> >      MsgBox("You do not have permission to do the job. " & _
>> >      "Please check your permissions on this item.")
>> >   Else
>> >      MsgBox("Request Failed.  Results = " & objRequest.Status & _
>> >      ": " & objRequest.statusText)
>> >   End If
>> > Catch ex As Exception
>> >   MsgBox(ex.Message)
>> > End Try
>> > objRequest = Nothing
>>
>> The destination URL can't be just the folder, you will need to provide a
>> new, unique URL if you want to create an item.  E.g.
>>
>> strURL = "http://texas/public/test/whatever-20071207-1347-85962.eml"
>>
>> Lee.
>>
>> -- 
>> ______________________________________
>>
>> Outlook Web Access For PDA , OWA For WAP
>> www.leederbyshire.com
>> email a@t leederbyshire d.0.t c.0.m
>> ______________________________________
>>
>>
>>
date: Fri, 7 Dec 2007 20:03:03 -0000   author:   Lee Derbyshire [MVP] email a@t leederbyshire d.0.t c.0.m

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us