I have REST API server on my vagrant machine. And I write client for it on c# (VS2015).
Have same code:
using (HttpClient client = new HttpClient())
{
client.BaseAddress = new Uri(_server);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = null;
try
{
response = await client.GetAsync(_action);
}
catch (HttpRequestException e)
{
Debug.WriteLine(e.Message);
}
}
Trouble:
Exception thrown: 'System.Net.Http.HttpRequestException' in mscorlib.ni.dll An error occurred while sending the request.
If I send request to another (non-vagrant) host, all is OK.
Question: How I can solve this?
Thanks)
UPDATED
Stack trace
Exception thrown: 'System.Net.Http.HttpRequestException' in mscorlib.ni.dll
mess: An error occurred while sending the request.
at System.Net.Http.HttpClientHandler.<SendAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Uborka.Models.ApiModel.<_Response>d__17.MoveNext()