>> public async Task getPromos(string url) >> { >> HttpClient client = new HttpClient(); >> client.BaseAddress = new Uri(url); >> var response = await client.GetAsync(client.BaseAddress); >> response.EnsureSuccessStatusCode(); >> var JsonResult = response.Content.ReadAsStringAsync().Result; >> var promo = JsonConvert.DeserializeObject<PromoResult>(JsonResult); >> SetValues(promo); >> } >>>>
>>04-13 15:43:15.120 D/Mono (22045): Remapped public key token of retargetable assembly System from 7cec85d7bea7798e to b77a5c561934e089 >>04-13 15:43:15.120 D/Mono (22045): The request to load the retargetable assembly System v2.0.5.0 was remapped to System v2.0.5.0 >>04-13 15:43:15.122 D/Mono (22045): Unloading image System.dll [0x687ebbe0]. >>04-13 15:43:15.122 D/Mono (22045): Image addref System[0x687ed778] -> System.dll[0x66e3b8d0]: 4 >>04-13 15:43:15.123 D/Mono (22045): Assembly Ref addref Newtonsoft.Json[0x661d6b50] -> System[0x66e50628]: 12 >>04-13 15:43:15.187 D/Mono (22045): Remapped public key token of retargetable assembly System.Runtime.Serialization from 7cec85d7bea7798e to b77a5c561934e089 >>04-13 15:43:15.187 D/Mono (22045): The request to load the retargetable assembly System.Runtime.Serialization v2.0.5.0 was remapped to System.Runtime.Serialization v2.0.5.0 >>04-13 15:43:15.189 D/Mono (22045): Unloading image System.Runtime.Serialization.dll [0x688487b8]. >>04-13 15:43:15.189 D/Mono (22045): Image addref System.Runtime.Serialization[0x68844e08] -> System.Runtime.Serialization.dll[0x6793c188]: 4 >>04-13 15:43:15.189 D/Mono (22045): Assembly Ref addref Newtonsoft.Json[0x661d6b50] -> System.Runtime.Serialization[0x6790e188]: 3 >>Loaded assembly: Anonymously Hosted DynamicMethods Assembly [External] >>04-13 15:43:15.451 D/Mono (22045): Assembly Ref addref m2m[0x65d48a08] -> System.Diagnostics.Debug[0x66154e28]: 3 >>>
var JsonResult = await response.Content.ReadAsStringAsync().Result;I tried that and the IDE gave me an error. I do have an await in the GetAysnc call and I have verified stepping through the code that JsonResult is populated. PromoResult is defined here:
namespace m2m { public class PromoResult { public PromotionObserver promotionObserver { get; set; } } } namespace m2m { public class PromotionObserver { public int autocouponlinkpk { get; set; } public int subscriberfk { get; set; } public DateTime enddate { get; set; } public bool hidesharebutton { get; set; } public bool iscoupon { get; set; } public string coupdescrp { get; set; } public bool globalcoupon { get; set; } public string imageurl { get; set; } public string market_descrp { get; set; } public string globallogo { get; set; } } }