static ArticlesCollection GetArticles(HttpClient httpClient, string searchString, int resultsCount)
{
string searchUrl = string.Format("search.json?q={0}&count={1}", searchString, resultsCount);
HttpResponseMessage response = httpClient.GetAsync(searchUrl).Result;
if (response.IsSuccessStatusCode)
{
ArticlesCollection articles = response.Content.ReadAsAsync<ArticlesCollection>().Result;
return articles;
}
else
{
throw new HttpRequestException(string.Format("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase));
}
}
}