It is pretty easy to apply
Dim WEB = New Net.WebClient()
WEB.Headers("Content-Type") = "application/json"
WEB.Headers("Authorization") = "Bearer " & varTokenTry
result = WEB.UploadString(varURL&, "POST", "")
Catch ex As Exception
Return ("")
End TryReturn 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
From Evnvoy FW7, Just can login into Enovy using Bearer Token,
I have made a simple code using VB.NET to
(1) Retrieve a Token from Enphase Token Website
(2) Using the Token, access Enovy's Data
Note. Need to add a certification validating code for Envoy, because envoy's certification is not valid.
Note. Ihave added json.vb for JSON file decord and using in the code