Fill List from WebRequest Error

Code worked, but now not working... Why?

var request = HttpWebRequest.Create("http://api.yandexzaim.ru/api/mobile/GETHome");
                request.ContentType = "application/json";
                request.Method = "GET";

                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    if (response.StatusCode != HttpStatusCode.OK)
                        Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
                    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    {
                        var content = reader.ReadToEnd();
                        if(string.IsNullOrWhiteSpace(content)) {
                            Console.Out.WriteLine("Response contained empty body...");
                        }
                        else {
                            var list = new List<DummyListViewData> ();
                            list = JsonConvert.DeserializeObject<List<DummyListViewData>> (content);

                            listview.Adapter = new ListView_Adapter(this, list);

                        }


                    }
                }

Posts

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    The exception is on "listview.Adapter = new ..." row?
    have you initialized "listview" or it's null?

Sign In or Register to comment.