My code in Vb.net looks like this:
how do it in b4a?
Dim lampstatus As String = "true"
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
lampstatus = "true"
Else
lampstatus = "false"
End If
Dim result As String
Dim MyURL As String, postData As String
Dim winHttpReq As Object
winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
MyURL = "
http://192.168.1.5/api/newdeveloper/lights/" & "1" & "/state"
postData = "{""on"": " & lampstatus & "}"
winHttpReq.Open("PUT", MyURL, False)
winHttpReq.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
winHttpReq.Send(postData)
result = winHttpReq.ResponseText
REM CheckBox1.Text = result
End Sub