For my reference and a future reference to anyone using Visual Basic:Install the Newtonsoft.json package. Also, import these namespaces:
Imports System.IO
Imports System.Net
Imports System.Text
Imports Newtonsoft.Json.Linq
Add this function to your code:
Function HttpPost() As JObject
' JSON Data
Dim postData As String = "Email=YOUR@EMAIL.COM&APIToken=YOURTOKEN"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
' HTTP Request
Dim request As WebRequest = WebRequest.Create("https://www.warlight.net/API/GameFeed?GameID=12269473")
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
And here's an example of retrieving data:
Dim dataName As String = HttpPost.SelectToken("name").ToString ' Will return the game's name.
I know that hardly anyone uses VB anymore, but this may come in handy to someone.