I am trying to download an image from the open weather org i have the following code.
I am using an Android Device to test my application and gave it the appropriate internet permissions.
I am using the example JSON here
I no my json decoding is working fine as I see the image name in the result set under the weather object.
public class Weather { public int id { get; set; } public string main { get; set; } public string description { get; set; } public string icon { get; set; } } public async void GetWeather () { result = await restServices.GetWeatherRequest(); lblweather.Text = result.main.temp.ToString(); string url = $"https://openweathermap.org/img/w/{result.weather[0].icon}.png"; imgWeather.Source = new UriImageSource { Uri = new Uri(url), CachingEnabled = true, CacheValidity = new TimeSpan(5, 0, 0, 0) }; } } My Main Xaml
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="WeatherApp.Views.WeatherMain"> <ContentPage.Content> <StackLayout> <Label Text="Welcome to Xamarin.Forms!" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" /> <Image x:Name="imgWeather"></Image> <Label x:Name="lblweather" ></Label> </StackLayout> </ContentPage.Content> </ContentPage> This is the URL that is created by my program which you will see is a valid point.
urlis actually valid and can be loaded in the device/emulator browser?