scott oliver

scott oliver

  • NA
  • 82
  • 16.3k

Problems looping through restresponse

Oct 11 2020 12:38 PM
Hello I am running into an issue writing the response from from a restSharpRequest. It gets the data fine and writes the file fine. I want to print out the information to see what I am dealing with so I can store it in a sqlite database. WHen I loop through the information it only prints one letter at a time per line. so the console prints one letter at a time. Here is a screen shot.
 
  1. var restSharpClient = new RestClient("https://www.otcmarkets.com");
  2. var downloadRequest = new RestRequest("research/stock-screener/api/downloadCSV?pageSize=20",
  3. Method.GET);
  4. var fileInBytes = restSharpClient.DownloadData(downloadRequest);
  5. File.WriteAllBytes(@"C:\Users\OpenUser\Documents\Stock Reports\OTC\OTCStockData.csv",
  6. fileInBytes);
  7. IRestResponse response = restSharpClient.Execute(downloadRequest);
  8. foreach(var i in (dynamic)(response.Content))
  9. {
  10. Console.WriteLine(i);
  11. }

Answers (1)