I have a problem with my universal app project (Universal Windows 8.1). I want to download a string which I then deserialize to a classes. But I encourage a problem with downloading this string on windows phone. I have a separate lib. Where I have only httpclient which downloads string and then deserialize it to classes. Everything works fine (tests are green), but when I plug it into windows phone app project. It looks like, it goes inside library code, but doesn't download anything.. I move code to download string to a windows phone solution to check why it doesn't work. But right now I'm constantly getting an exception like this:
System.Exception: Exception from HRESULT: 0x80072F30
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ProjectName.Mobile.MainPage.<InitComboBoxes>d__10.MoveNext()
Here is my code:
private HttpClient client;
private CancellationTokenSource cts;
private HttpBaseProtocolFilter filter;
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
filter = new HttpBaseProtocolFilter();
client = new HttpClient(filter);
cts = new CancellationTokenSource();
await InitComboBoxes();
}
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
filter?.Dispose();
client?.Dispose();
cts?.Dispose();
}
private async Task InitComboBoxes()
{
try
{
var response = await client.GetAsync(new Uri(@"http://planer.info.pl/api/rest/places.json")).AsTask(cts.Token);
var t = await response.Content.ReadAsStringAsync().AsTask(cts.Token);
}
catch (Exception e)
{
var msg = new MessageDialog("Please check Your internet connection!" + e.Message);
await msg.ShowAsync();
}
}
Right now I don't have any idea how to resolve this problem.. If anyone could help me I will be very grateful!