I have a problem staying authenticated on a website.
this code works. no authentication requerd.
however if i change the url into this one (https://tradingpost-live.ncplatform....max=80&count=0)
I get an error "The remote server returned an error: (401) Unauthorized." what i expected.
Now how can i keep my program to know i'm authenticed? by using this url as authentication.
KeyUrl = "https://tradingpost-live.ncplatform.net/authenticate?session_key=" + Key
this code works. no authentication requerd.
Code:
'We this to make an HTTP web request
Dim req As Net.HttpWebRequest = Net.WebRequest.Create("https://api.guildwars2.com/v1/map_names.json")
'Make the web request and get the response
Dim response As Net.WebResponse = req.GetResponse
Dim stream As System.IO.Stream = response.GetResponseStream
'Prepare buffer for reading from stream
Dim buffer As Byte() = New Byte(1000) {}
'Data read from stream is gathered here
Dim data As New List(Of Byte)
'Start reading stream
Dim bytesRead = stream.Read(buffer, 0, buffer.Length)
Do Until bytesRead = 0
For i = 0 To bytesRead - 1
data.Add(buffer(i))
Next
bytesRead = stream.Read(buffer, 0, buffer.Length)
Loop
'Gets the JSON data
Debug.WriteLine(System.Text.Encoding.UTF8.GetString(data.ToArray))
response.Close()
stream.Close()I get an error "The remote server returned an error: (401) Unauthorized." what i expected.
Now how can i keep my program to know i'm authenticed? by using this url as authentication.
Quote:
KeyUrl = "https://tradingpost-live.ncplatform.net/authenticate?session_key=" + Key
Code:
'We this to make an HTTP web request
Dim req As Net.HttpWebRequest = Net.WebRequest.Create("https://tradingpost-live.ncplatform.net/ws/search.json?text=ectopl&levelmin=0&levelmax=80&count=0")
'Make the web request and get the response
Dim response As Net.WebResponse = req.GetResponse
Dim stream As System.IO.Stream = response.GetResponseStream
'Prepare buffer for reading from stream
Dim buffer As Byte() = New Byte(1000) {}
'Data read from stream is gathered here
Dim data As New List(Of Byte)
'Start reading stream
Dim bytesRead = stream.Read(buffer, 0, buffer.Length)
Do Until bytesRead = 0
For i = 0 To bytesRead - 1
data.Add(buffer(i))
Next
bytesRead = stream.Read(buffer, 0, buffer.Length)
Loop
'Gets the JSON data
Debug.WriteLine(System.Text.Encoding.UTF8.GetString(data.ToArray))
response.Close()
stream.Close()