Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMaggie Nasho
6,212 Pointshelp plz
Challenge Task 1 of 4
In the GetTreehouseHome method, create a new WebClient object named webClient. The WebClient class implements IDisposable, so wrap it in a using statement.
using (var webClient = WebClient())
var client = WebClient();
{
webClient.Headers.Add("Ocp-Apim-Subscription-Key", "5739a899674c4b92955879175f5c3c26");
byte[] ByteData = webClient.DownloadData(string.Format("https://api.cognitive.microsoft.com/bing/v5.0/news/search?q={0}&mkt=en-us", topic[0]));
using (var memStream = new MemoryStream(ByteData))
using (var reader = new StreamReader(memStream))
using (var jreader = new JsonTextReader(reader))
{
var cereal = new JsonSerializer();
return cereal.Deserialize<NEWS>(jreader).NewsResults;
}
}
1 Answer
Steven Parker
231,072 PointsYou did something odd here.
You need to add to the code provided initially by the challenge. But it looks like you removed all the original code.
Also, the code added here is far more elaborate and not directly related to what the challenge is asking for. It kind of looks like you copied some code from somewhere and pasted it in?
Try starting over, read the instructions carefully, and add only the code needed at the point where the challenge has the comment: "// Put code here".