I have a really strange error which has been driving me mad for days.
I'm running the following code within my Visual Studio development environment and getting the error "An unexpected error occurred on a send". Compile the code and move it to a machine that does not have Visual Studio and it works fine
Environment is .Net 4.7.1 using Visual Studio 2015
public string Get(string resource)
{
string url = BuildResourceUrl(resource);
try
{
WebRequest req = WebRequest.Create(url);
req.Method = "GET";
req.ContentType = "application/json";
req.Headers.Add("X-Shopify-Access-Token", _apiPassword);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
WebResponse response = req.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
return responseFromServer;
}
catch (WebException ex)
{
string response;
using (var reader = new StreamReader(ex.Response.GetResponseStream()))
{
response = reader.ReadToEnd();
}
throw ex;
}
}
I have disabled all Firewalls and AntiVirus but this makes no difference.
Help on resolving this would be most appriciated