|
I have adapted you Full HTTP POST Example to VB.Net. (Code at end.) When I run it, it write a file containing your web page requesting username/password rather than the actual data. I used your example in C# as is (with appropriate URL and username/password) and got the same result. (The only thing I had to leave out was "Using System.Collections.Generic" which was giving me an error. I am using VS 2003.)
What am I missing? Here is the VB code:
---------------------------------------------------------------------------------------------------------------------------------------
Private Sub btDnldRapsheet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btDnldRapsheet.Click
Dim URL As String = "https://www.rapnet.com/Rapnet/Prices/DownloadPriceSheet.aspx?PriceFormat=CSV2_ROUND"
Dim webRequest As System.Net.WebRequest = System.Net.WebRequest.Create(URL)
webRequest.Method = "POST"
webRequest.ContentType = "application/x-www-form-urlencoded"
Dim reqStream As Stream = webRequest.GetRequestStream()
Dim postData As String = "username=xxxxxxxx&password=xxxxxxxxxx"
Dim postArray As Byte() = Encoding.ASCII.GetBytes(postData)
reqStream.Write(postArray, 0, postArray.Length)
reqStream.Close()
Dim sr As New StreamReader(webRequest.GetResponse().GetResponseStream())
Dim Result As String = sr.ReadToEnd()
Dim tw As TextWriter = New StreamWriter("c:\result.csv", True)
tw.Write(Result)
End Sub
---------------------------------------------------------------------------------------------------------------------------------------
Thanks in advance,
Joe
|
>> add a comment
|
Joe Shurpin
01/27/2010 12:19
|
|
2
Replies:
|
Hi,
two things:
1. The URL should be: https://technet.rapaport.com/HTTP/Prices/CSV2_Round.aspx
2. If you have any special characters in your password, you may have to add URLEncoding to that.
Hope this helps,
Regards,
Leo
|
>> add a comment
|
Leo Muller
1/28/2010 2:13:00 AM
|
|
|
Thank you very much - it was the URL.
Joe
|
>> add a comment
|
Joe Shurpin
1/28/2010 8:52:00 AM
|
|