I have a web api which connects to azure devops repo and retrieves some files to do some operations. Problem is, I am unable to connect from the web service. I get the error "SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond". However, the same code runs perfectly fine in a console application.
VssConnection connection = new VssConnection(new Uri("https://dev.azure.com/org"), new VssBasicCredential(string.Empty, "psa"));
TfvcHttpClient tfvcClient = connection.GetClient<TfvcHttpClient>(); //error here
string projectName = "Project";
string scopePath = $"$/{projectName}/";
List<TfvcItem> items = tfvcClient.GetItemsAsync(scopePath: scopePath, recursionLevel: VersionControlRecursionType.OneLevel).Result;
Console.WriteLine("Connection Established");
Strangely, once I establish connection through the console application, if I run the same code through the web service, it works. I turned off firewall and checked but nothing works. Been stuck for so long!