Skip to main content

Call API from ASP.NET using VB - Authentication failed

  • November 15, 2017
  • 1 reply
  • 91 views

I'm trying to connect to the Freshdesk API from asp.net 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!


Thanks.


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

Dim wHeader As WebHeaderCollection = New WebHeaderCollection()

wHeader.Clear()

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

Dim wRequest As HttpWebRequest = CType(System.Net.HttpWebRequest.Create("https://xxxxxx.freshdesk.com/api/v2/tickets"), HttpWebRequest)

wRequest.Headers = wHeader

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

wRequest.Method = "GET"

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

This topic has been closed for replies.

1 reply

  • Apprentice
  • March 13, 2018
FYI, I fixed this by specifying the security protocol:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;