public async Task <WikiGeoSearchRoot> GetWikiGeoSearchAsync() { WikiGeoSearchRoot geoSearch = null; try { using (var client = new HttpClient()) { var queryParams = "format=json&list=geosearch&gscoord=37.786952%7C-122.399523&gsradius=10000&gslimit=10"; // var response = await client.GetStringAsync(rootUrl + queryParams); Console.WriteLine(response.ToString()); if (response != null) { geoSearch = JsonConvert.DeserializeObject <WikiGeoSearchRoot>(response); } return(geoSearch); } } catch (WebException exception) { throw new WebException( "An error has occurred while calling GetSampleClass method: " + exception.Message); } }
public WikiGeoSearchRoot GetWikiGeoSearch() { WikiGeoSearchRoot geoSearch = null; try { using (var webClient = new WebClient()) { webClient.Encoding = System.Text.Encoding.UTF8; var queryParams = "format=json&list=geosearch&gscoord=37.786952%7C-122.399523&gsradius=10000&gslimit=50"; // SearchQuery = rootUrl + queryParams; // open and read from the supplied URI Stream stream = webClient.OpenRead(new Uri(SearchQuery)); StreamReader reader = new StreamReader(stream); string response = reader.ReadToEnd(); Console.WriteLine(response.ToString()); if (response != null) { geoSearch = JsonConvert.DeserializeObject <WikiGeoSearchRoot>(response); } return(geoSearch); } } catch (WebException exception) { throw new WebException( "An error has occurred while calling GetSampleClass method: " + exception.Message); } }