1 Reply Latest reply on Dec 16, 2016 5:00 PM by Marcos Vainer Loeff

    Copying data from URL through VB.net

    Tanmay

      This is the code I am using to copy some data from a URL to text file:

       

       

      Imports System.Net
      Imports System.IO

      Public Class Form1
        
      Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        
      Dim request As WebRequest = WebRequest.Create("https://01hw860645vm7/piwebapi/streams/P0RCrLRNEwjUSpQKLB67jLng60cAAAMDFIVzg2MDY0NVZNN1xBR0lfQ1VSUkVOVA/value")
        
      Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
        
      Dim datastream As Stream = response.GetResponseStream
        
      Dim reader As New StreamReader(datastream)
        
      Dim strdata As String = reader.ReadToEnd
        
      Dim file As System.IO.StreamWriter
        file
      = My.Computer.FileSystem.OpenTextFileWriter("C:\Users\1212832\Desktop\Test.txt", True)
        file
      .WriteLine(strdata)
        file
      .Close()
        TextBox1
      .Text = strdata
        
      End Sub
      End Class

       

      And I am getting the following error: "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

      I am totally new to this and facing small issues. Any help would be appreciated. Thanks in advance.