This function works but I'd like to convert it to HttpClient so I can set a Timeout and also because I'm told the WebClient is obsolete :
Many thanks
VB.NET:
Function RelayControl() As String
Dim ret_state As String
Dim client As New WebClient
client.Credentials = New NetworkCredential("admin", "1234")
client.QueryString.Add("value", "false")
Try
client.UploadValues("[URL]http://192.168.1.101:80/restapi/relay/outlets/0/state/[/URL]", "PUT", client.QueryString)
ret_state = client.DownloadString("[URL]http://192.168.1.101:80/restapi/relay/outlets/0/state/[/URL]")
Catch e As Exception
Return "Error"
End Try
Return ret_state
End Function
Many thanks
Last edited by a moderator: