title: getting json data from url in c#
body: <p>I'm trying to get json data from the below url in to a C# project into anything, before I can parse/use the data in a chart:</p>
  
  <blockquote>
    <p><a href="https://cex.io/api/ohlcv/hd/20160228/BTC/USD" rel="nofollow noreferrer">https://cex.io/api/ohlcv/hd/20160228/BTC/USD</a></p>
  </blockquote>
  
  <p>I was actually retrieving the json data by sendin json requests with a websocket but for some reason couldn't get any data with this.So I decided to get the data without providing any json request, as the link was simple.But whatever I tried I ended up with either empty returns or error.At one point I've managed to add a huge chunk of data to the ListBox(seemed like a full html page with some data I needed but I couldn't understand where the whole html code also came from as the link only has json) but that was useless as well. When tried </p>
  
  <p><strong>WebRequest</strong> with <strong>HttpWebRequest</strong> it didn't recognize WebRequest even with the correct system.net.http and all the rest included.(tried to add manually to References..but they were already checked on the list)
  <strong>WebClient</strong> returns empty or useless object or variable type names. <strong>HttpClient</strong> also didn't work but can't remember what it didn't recognize. When I hit the rock bottom I even tried to put a <em>webBrowser</em> object and tried to read it from there but then noticed that this shouldn't be that hard, and decided to ask.</p>
  
  <p>Here is what I have done so far:</p>
  
  <pre><code>  //HttpClient client3 = new HttpClient();
                               string url = textBox8.Text + listBox3.GetItemText(listBox3.SelectedItem) + listBox4.GetItemText(listBox4.SelectedItem);
  
                               MessageBox.Show(url);
  
  
                               //System.Uri uri = new System.Uri(url);
                               //webBrowser1.Url = uri;
  
                               System.Net.WebClient client8 = new System.Net.WebClient();
                               //client8.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"); //I dont know if this was needed but seen it on a different example and just added.
                               var html = client8.DownloadString(url);   //returns empty
                               var html2 = client8.DownloadData(url); //adds the line "System.Byte[]"
                               var html3 = client8.OpenRead(url); //adds something like "System.blabla.connectstream"
                               MessageBox.Show(html);
  
  
                               listBox1.Items.Add(html2.ToString());
                               listBox1.Items.Add(html3);
  </code></pre>
  
  <p>I'd appreciate if someone could help.</p>