Working VB example for Local Weather Push via Rest API
I can get the curl utility working without issues. Can someone please give an example of working VB.Net code(Preferably) or Java code that will bypass the self signed cert, authenticate and send the data please.
This is what I have currently:
Public Class Program
Public Shared Sub Main(args As String())
System.Net.ServicePointManager.ServerCertificateValidationCallback = Function(s, c, h, e) True
Dim request = TryCast(System.Net.WebRequest.Create("https://192.168.0.85:8080/api/4/login/auth"), System.Net.HttpWebRequest)
request.Method = "POST"
request.ContentType = "application/json"
Using writer = New System.IO.StreamWriter(request.GetRequestStream())
Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes("{
\""user\"": {
\""email\"": \""{{mail@email.com}}\"",
\""pwd\"": \""{{Password}}\"",
\""remember\"": true
}
}")
request.ContentLength = byteArray.Length
writer.Write(byteArray)
writer.Close()
End Using
Dim responseContent As String
Using response = TryCast(request.GetResponse(), System.Net.HttpWebResponse)
Using reader = New System.IO.StreamReader(response.GetResponseStream())
responseContent = reader.ReadToEnd()
End Using
End Using
End Sub
End Class
Please sign in to leave a comment.
Comments
2 comments