By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,327 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,327 IT Pros & Developers. It's quick & easy.

XML post with VB

P: n/a
Hi this code works great to send an XML file to the server without
But when authentication switched on (basic) the credentials do no get
picked up and so the post does not arrive on the server

Anyone see why ?
Dim inputStream As New FileStream(filePath, FileMode.Open,
FileAccess.Read, FileShare.Read)
Dim inputLength As Integer = CInt(inputStream.Length)
Dim inputBody(inputLength) As Byte
inputStream.Read(inputBody, 0, inputLength)

' Create WebRequest and set headers
Dim req As HttpWebRequest =
CType(WebRequest.Create(postUrl), HttpWebRequest)
Dim myCred As New
System.Net.NetworkCredential(postUsername, postPassword)
req.Credentials = myCred

req.Method = "POST"
req.ProtocolVersion = HttpVersion.Version11
req.ContentType = "text/xml"
req.ContentLength = inputLength
If 0 < mTimeout Then
req.Timeout = mTimeout
End If
' Write the input to the request stream

Dim reqStream As Stream = req.GetRequestStream()
reqStream.Write(inputBody, 0, inputLength)

Nov 13 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.