C# C# Streams and Data Processing Streaming Data on the Net WebClient

help 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
Steven Parker
182,340 Points

You 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".