Call API from ASP.NET using VB - Authentication failed

I'm trying to connect to the Freshdesk API from but I'm getting the following error:

Authentication failed because the remote party has closed the transport stream.

The code I am using is as follows.  Any help is greatly appreciated!


Dim Authorization As String = Convert.ToBase64String(System.Text.Encoding.Default.GetBytes("apikey:x"))

Dim wHeader As WebHeaderCollection = New WebHeaderCollection()


wHeader.Add("Authorization","Basic " + Authorization)

Dim wRequest As HttpWebRequest = CType(System.Net.HttpWebRequest.Create(""), HttpWebRequest)

wRequest.Headers = wHeader

wRequest.ContentType = "application/json; charset=utf-8"

wRequest.Method = "GET"

Dim wResponse As HttpWebResponse = CType(wRequest.GetResponse(), HttpWebResponse)

1 person has this question
1 Comment

FYI, I fixed this by specifying the security protocol:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;



Login or Signup to post a comment