05/01/2023 11:21 (*.17.160.158)
2673

To answer on FORM/POST for login

 

Dim result As String = ""
Dim WEB = New Net.WebClient()

 

Dim LoginData As System.Collections.Specialized.NameValueCollection = New System.Collections.Specialized.NameValueCollection()

LoginData.Add("user[email]", ID)       // depend on the form field title
LoginData.Add("user[password]", PW)    // depend on the form field title

 

Try
   result = Text.Encoding.UTF8.GetString(WEB.UploadValues(URL, "POST", LoginData))
Catch ex As Exception
   result = ""
End Try

05/01/2023 11:17 (*.17.160.158)
488

It is pretty easy to apply

 

Dim WEB = New Net.WebClient()

WEB.Headers("Content-Type") = "application/json"
WEB.Headers("Authorization") = "Bearer " & varToken

Try
    result = WEB.UploadString(varURL&, "POST", "")
 Catch ex As Exception
    Return ("")
End Try

Return result

 

Just add a token into header, and can access URL

 

 

There are so many web base devices, and some webserver device do not have a valid certification,

While access HTTPS using Webclient, will get a trouble with Certification if there is no valid one.

When I access Envoy Local Servier using HTTPS, I have expericed it.

 

First, create a Validation Server Function as below

 

Public Function ValidateServerCertificate(ByVal sender As Object, ByVal certificate As Object, ByVal chain As Object, ByVal sslPolicyErrors As Net.Security.SslPolicyErrors) As Boolean


        Return True


End Function

 

And, Connect the validate server as

 

Net.ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf ValidateServerCertificate)

 

When call HTTPS using Webclient, Webclient server will call the user defined server code, and can over-ride an error 

 

You can put the code into MAIN() -0r-  Sub New() once