How to retrive json string from Url in Xamarin.forms pcl
Your snippet looked all OK to me and I just gave it a try and it worked like charm for me. I got JSON string in content variable and I could deserialize it also. Here am sharing the snippet I used.
public static async Task RefreshDataAsync () { var uri = new Uri ("http://www.pizzaboy.de/app/pizzaboy.json"); HttpClient myClient = new HttpClient(); var response = await myClient.GetAsync (uri); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync (); var Items = JsonConvert.DeserializeObject <List<RootObject>> (content); Console.WriteLine (""); } }
Here is my definition for the class RootObject I used
public class RootObject{ public string Name { get; set; } public string Address1 { get; set; } public int Zip { get; set; } public string City { get; set; } public string Phone { get; set; } public double Lat { get; set; } public double Lon { get; set; } public string Link { get; set; }}