1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Dim httpRequest As HttpWebRequest
httpRequest = DirectCast(WebRequest.Create("https://mywebsite.com/api/organizations"), HttpWebRequest)
httpRequest.Credentials = New NetworkCredential(tbMooUser.Text, tbMooPassword.Text)
httpRequest.Method = "GET"
httpRequest.Accept = "application/vnd.monsoon.v1+json"
httpRequest.ContentType = "application/json"
Dim httpWebResponse As HttpWebResponse = DirectCast(httpRequest.GetResponse(), HttpWebResponse)
Dim responseStream As Stream = httpWebResponse.GetResponseStream()
Dim sb As New StringBuilder()
Dim line As String
Using reader As New StreamReader(responseStream, System.Text.Encoding.UTF8)
line = reader.ReadLine
Do While (Not line Is Nothing)
Debug.WriteLine(line)
sb.AppendLine(line)
line = reader.ReadLine
Loop
End Using
Dim result As String = sb.ToString
Dim Testobject As Organisation() = Global.Newtonsoft.Json.JsonConvert.DeserializeObject(Of Organisation())(result)
For Each Organisation In Testobject
ddlOrganisation.Items.Add(Organisation.name)
Next |
Partager