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: 14 Mar 2007 05:51:22 -0700,    group: microsoft.public.exchange.development        back       


I get always 400 bad request with webdav   
Hi,
I'm trying to connect to a public folder of exchange with webdav. this
is the code that I run, but I always receive 400 bad request message.
I've tried different queries but the result is always the same:


Dim URI As String = "http://serverip/Public/foldername/"
Dim query As String = ""
query = "<?xml version=""1.0""?>" & _
	"<D:searchrequest xmlns:D = ""DAV:""><D:sql>" & _
	"SELECT ""urn:schemas:httpmail:subject""" & _
	",""urn:schemas:contacts:email1""" & _
	" FROM scope('shallow traversal of """ & uri & """')" & _
	" WHERE ""DAV:ishidden"" = 0" & _
	" AND ""DAV:isfolder"" = 0" & _
	"</D:sql></D:searchrequest>"

' Variables
Dim SysRequest As System.Net.HttpWebRequest
Dim SysResponse As System.Net.HttpWebResponse
Dim MyCredentialCache As System.Net.CredentialCache
Dim strUserName, strPassword, strDomain As String
Dim bytes() As Byte
Dim RequestStream As System.IO.Stream
Dim ResponseStream As System.IO.Stream



' Initialize variables.
strUserName = "administrator"
strPassword = "password"
strDomain = "domain"

bytes = System.Text.Encoding.UTF8.GetBytes(query) ' Encode the body
using UTF-8.

' Create a new CredentialCache object and fill it with the network
credentials required to access the server.
MyCredentialCache = New System.Net.CredentialCache
MyCredentialCache.Add(New System.Uri(URI), "Basic", _
	New System.Net.NetworkCredential(strUserName, strPassword,
strDomain))

SysRequest = CType(System.Net.WebRequest.Create(URI),
System.Net.HttpWebRequest) ' Create the PUT HttpWebRequest object.

With SysRequest
	.Credentials = MyCredentialCache ' Add the network credentials to the
request.
	.Method = "SEARCH"     ' Specify the SEARCH method.
	.ContentLength = bytes.Length  ' Set the content header length.  This
must be done before writing data to the request stream.
	.ContentType = "text/xml"   ' Set the Content Type header.
	.Headers.Add("Translate", "f")  ' Set the Translate header.
End With


RequestStream = SysRequest.GetRequestStream() ' Get a reference to the
request stream.
With RequestStream
	.Write(bytes, 0, bytes.Length)  ' Write the message body to the
request stream.
	.Close()        ' Close the Stream object to release the connection
for further use.
End With

' Send the SEARCH method request and get the response from the
server.
SysResponse = CType(SysRequest.GetResponse(),
System.Net.HttpWebResponse)
ResponseStream = SysResponse.GetResponseStream() ' Get the XML
response stream.

....
the exception is rised by SysRequest.GetResponse()

Thank you very much for your time.
bye
Giulio
date: 14 Mar 2007 05:51:22 -0700   author:   unknown

Re: I get always 400 bad request with webdav   
Hello,

DAV:ishidden and DAV:isfolder are boolean properties. Thus, you should 
compare them to false:

WHERE "DAV:ishidden" = false

Best regards,
Henning Krause

 wrote in message 
news:1173876682.343939.185900@d57g2000hsg.googlegroups.com...
> Hi,
> I'm trying to connect to a public folder of exchange with webdav. this
> is the code that I run, but I always receive 400 bad request message.
> I've tried different queries but the result is always the same:
>
>
> Dim URI As String = "http://serverip/Public/foldername/"
> Dim query As String = ""
> query = "<?xml version=""1.0""?>" & _
> "<D:searchrequest xmlns:D = ""DAV:""><D:sql>" & _
> "SELECT ""urn:schemas:httpmail:subject""" & _
> ",""urn:schemas:contacts:email1""" & _
> " FROM scope('shallow traversal of """ & uri & """')" & _
> " WHERE ""DAV:ishidden"" = 0" & _
> " AND ""DAV:isfolder"" = 0" & _
> "</D:sql></D:searchrequest>"
>
> ' Variables
> Dim SysRequest As System.Net.HttpWebRequest
> Dim SysResponse As System.Net.HttpWebResponse
> Dim MyCredentialCache As System.Net.CredentialCache
> Dim strUserName, strPassword, strDomain As String
> Dim bytes() As Byte
> Dim RequestStream As System.IO.Stream
> Dim ResponseStream As System.IO.Stream
>
>
>
> ' Initialize variables.
> strUserName = "administrator"
> strPassword = "password"
> strDomain = "domain"
>
> bytes = System.Text.Encoding.UTF8.GetBytes(query) ' Encode the body
> using UTF-8.
>
> ' Create a new CredentialCache object and fill it with the network
> credentials required to access the server.
> MyCredentialCache = New System.Net.CredentialCache
> MyCredentialCache.Add(New System.Uri(URI), "Basic", _
> New System.Net.NetworkCredential(strUserName, strPassword,
> strDomain))
>
> SysRequest = CType(System.Net.WebRequest.Create(URI),
> System.Net.HttpWebRequest) ' Create the PUT HttpWebRequest object.
>
> With SysRequest
> .Credentials = MyCredentialCache ' Add the network credentials to the
> request.
> .Method = "SEARCH"     ' Specify the SEARCH method.
> .ContentLength = bytes.Length  ' Set the content header length.  This
> must be done before writing data to the request stream.
> .ContentType = "text/xml"   ' Set the Content Type header.
> .Headers.Add("Translate", "f")  ' Set the Translate header.
> End With
>
>
> RequestStream = SysRequest.GetRequestStream() ' Get a reference to the
> request stream.
> With RequestStream
> .Write(bytes, 0, bytes.Length)  ' Write the message body to the
> request stream.
> .Close()        ' Close the Stream object to release the connection
> for further use.
> End With
>
> ' Send the SEARCH method request and get the response from the
> server.
> SysResponse = CType(SysRequest.GetResponse(),
> System.Net.HttpWebResponse)
> ResponseStream = SysResponse.GetResponseStream() ' Get the XML
> response stream.
>
> ...
> the exception is rised by SysRequest.GetResponse()
>
> Thank you very much for your time.
> bye
> Giulio
>
date: Wed, 14 Mar 2007 06:20:42 -0700   author:   Henning Krause [MVP - Exchange]

Re: I get always 400 bad request with webdav   
thank you very much.
it works.
date: 14 Mar 2007 07:17:33 -0700   author:   unknown

Google
 
Web ureader.com


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