This is mainly for my own reference.
vb Code:
' Simple Request
Function HttpRequest(URL As String) As String
Dim request As WebRequest = WebRequest.Create(URL)
Dim dataStream As Stream = request.GetResponse.GetResponseStream()
Dim sr As New StreamReader(dataStream)
Return sr.ReadToEnd
End Function
' Post Request
Function HttpPost(URL as String, JSON as String) As JObject
' JSON Data
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(JSON)
' HTTP Request
Dim request As WebRequest = WebRequest.Create(URL)
request.Method = "POST"
' Requesting
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
' Recieving a Response
dataStream = request.GetResponse.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
dataStream.Close()
reader.Close()
Return JObject.Parse(responseFromServer)
End Function