I want to develop a program that uses an online API, with GET and POST requests, and I want to know how to make the requests within the program (without the user seeing a web page), and then download the results into the program so I can parse them
+3
A:
You're looking for the WebRequest
class. This example has been adapted from the msdn documentation:
Dim request As WebRequest = WebRequest.Create("http://www.example.com/example.html")
' Get the response.
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
' Get the stream containing content returned by the server.
Dim dataStream As Stream = response.GetResponseStream()
' Open the stream using a StreamReader for easy access.
Dim reader As New StreamReader(dataStream)
' Read the content.
Dim responseFromServer As String = reader.ReadToEnd()
Ken Browning
2009-03-18 21:29:44
K, how about for POST requests that also return data?
Luke
2009-03-18 21:39:53
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.method.aspx
Ken Browning
2009-03-18 21:44:21