Hi. I have REST API server on my vagrant machine. And I write client for it on c# (VS2015).
Have same code:
Code
using (HttpClient client = new HttpClient())Code
{Code
client.BaseAddress = new Uri(_server);Code
client.DefaultRequestHeaders.Accept.Clear();Code
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));Code
Code
HttpResponseMessage response = null;Code
Code
try {Code
response = await client.GetAsync("http://api.mysite.ru/getAll");Code
}Code
catch (HttpRequestException e)Code
{Code
Debug.WriteLine(e.Message);Code
}Code
}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?
F*cking with this for third day. Thanks)
Answers
Know the answer? Post it. Somebody with the same question will find it here.