Answered by:
Post and Response (XML)

Question
-
Haven't much luck resolving this issue on VB Language/General board. Thought I would try here.
Am using VB.Net to post to a website (internal) an xml block of text, and hoping to get an xml response back. I am implementing functionality documented by a third party and API. It's an FTP Appliance. http://docs.allardsoft.com/filetransfer/api.
I've tried variations on the code, getting back initially a 406 (Unacceptable) error back, am now getting 401 (Not AUthorized) back. Perhaps someone can tell me what I might be doing wrong here? Thank you!
Dim r As StreamReader Dim result As String Dim h As HttpWebRequest = WebRequest.Create("https://filetransfer.somewhere.com") Dim xml As String = "<?xml version=""1.0"" encoding=""UTF-8""?><user><email>someone@somewhere.com</email><password>somepassword</password></user>" Dim enc As New UTF8Encoding Dim byte1 As Byte() = enc.GetBytes(xml) h.Method = "POST" h.ContentType = "text/xml" h.ContentLength = byte1.Length Dim st As Stream = h.GetRequestStream() st.Write(byte1, 0, byte1.Length) st.Close() Dim response As WebResponse = h.GetResponse() r = New StreamReader(response.GetResponseStream) result = r.ReadToEnd txtResponse.Text = "" txtResponse.Text = result response.Close()
- Edited by ITMn0403 Wednesday, November 9, 2011 5:16 PM
- Moved by Yanping Wang Friday, November 11, 2011 9:51 AM (From:Internet Explorer Web Development)
Wednesday, November 9, 2011 5:16 PM
Answers
-
Hi ITMn0403,
This forum is dedicated to discuss about web development including HTML, CSS and Script for Internet Explorer, your post is off topic here. It looks like a problem from third party, if that, please contact that technical owner, otherwise, repost this question in the ASP.NET forums with concise steps for implementing functionality documented by a third party.
Thank you for your understanding and support.
Best regards,
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework- Proposed as answer by Ed Price - MSFTMicrosoft employee Thursday, December 22, 2011 5:58 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Thursday, December 29, 2011 9:33 PM
Friday, November 11, 2011 9:50 AM -
Find the ASP.NET forum here: http://forums.asp.net/
This is regarding your code:
Dim r As StreamReader Dim result As String Dim h As HttpWebRequest = WebRequest.Create("https://filetransfer.somewhere.com") Dim xml As String = "<?xml version=""1.0"" encoding=""UTF-8""?><user><email>someone@somewhere.com</email><password>somepassword</password></user>" Dim enc As New UTF8Encoding Dim byte1 As Byte() = enc.GetBytes(xml) h.Method = "POST" h.ContentType = "text/xml" h.ContentLength = byte1.Length Dim st As Stream = h.GetRequestStream() st.Write(byte1, 0, byte1.Length) st.Close() Dim response As WebResponse = h.GetResponse() r = New StreamReader(response.GetResponseStream) result = r.ReadToEnd txtResponse.Text = "" txtResponse.Text = result response.Close()
Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)- Proposed as answer by Ed Price - MSFTMicrosoft employee Thursday, December 22, 2011 5:59 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Thursday, December 29, 2011 9:33 PM
Thursday, December 22, 2011 5:59 AM
All replies
-
Hi ITMn0403,
This forum is dedicated to discuss about web development including HTML, CSS and Script for Internet Explorer, your post is off topic here. It looks like a problem from third party, if that, please contact that technical owner, otherwise, repost this question in the ASP.NET forums with concise steps for implementing functionality documented by a third party.
Thank you for your understanding and support.
Best regards,
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework- Proposed as answer by Ed Price - MSFTMicrosoft employee Thursday, December 22, 2011 5:58 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Thursday, December 29, 2011 9:33 PM
Friday, November 11, 2011 9:50 AM -
Find the ASP.NET forum here: http://forums.asp.net/
This is regarding your code:
Dim r As StreamReader Dim result As String Dim h As HttpWebRequest = WebRequest.Create("https://filetransfer.somewhere.com") Dim xml As String = "<?xml version=""1.0"" encoding=""UTF-8""?><user><email>someone@somewhere.com</email><password>somepassword</password></user>" Dim enc As New UTF8Encoding Dim byte1 As Byte() = enc.GetBytes(xml) h.Method = "POST" h.ContentType = "text/xml" h.ContentLength = byte1.Length Dim st As Stream = h.GetRequestStream() st.Write(byte1, 0, byte1.Length) st.Close() Dim response As WebResponse = h.GetResponse() r = New StreamReader(response.GetResponseStream) result = r.ReadToEnd txtResponse.Text = "" txtResponse.Text = result response.Close()
Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)- Proposed as answer by Ed Price - MSFTMicrosoft employee Thursday, December 22, 2011 5:59 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Thursday, December 29, 2011 9:33 PM
Thursday, December 22, 2011 5:59 AM