I am going to integrate an existing c# project into a legacy VB.net system. the below code works in C# perfectly
private string GETShopify(string CallLoc, string APIKey, string Password, string StoreName)
{
string Str = APIKey + ":" + Password;
byte[] byt = System.Text.Encoding.UTF8.GetBytes(Str);
Str = System.Convert.ToBase64String(byt);
string Url = "https://" + StoreName + ".myshopify.com/admin/" + CallLoc;
WebRequest request = WebRequest.Create(Url);
NetworkCredential SimpleCredential = new NetworkCredential(APIKey, Password);
request.Credentials = SimpleCredential;
request.Headers.Add("Authorization", "Basic " + Str);
request.ContentType = "application/json";
request.Method = "GET";
WebResponse response = request.GetResponse();
}
However VB is failing on GetResponce
Private Function GETShopify(ByVal CallLoc As String, ByVal APIKey As String, ByVal Password As String, ByVal StoreName As String) As String
Dim Str As String = APIKey & ":" & Password
Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(Str)
Str = System.Convert.ToBase64String(byt)
Dim Url As String = "https://" & StoreName & ".myshopify.com/admin/" & CallLoc
Dim request As WebRequest = WebRequest.Create(Url)
Dim SimpleCredential As NetworkCredential = New NetworkCredential(APIKey, Password)
request.Credentials = SimpleCredential
request.Headers.Add("Authorization", "Basic " & Str)
request.ContentType = "application/json"
request.Method = "GET"
Dim response As WebResponse = request.GetResponse() <<FAIL
End Function
System.Net.WebException HResult=0x80131509 Message=The underlying connection was closed: An unexpected error occurred on a send.
Inner Exception 1: IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Inner Exception 2: SocketException: An existing connection was forcibly closed by the remote host
I cannot find a cause for this. the code is extremely simple so wouldnt imagine this much of an issue.
If anyone has ever hit this issue before or has any suggestions that would be fantastic.