title: using GET to get JSON data from multiple pages
body: <p>I need to get data from URL. </p>
  
  <ol>
  <li><p>The code below gives the error "reading past end of file". Yet the URL is correct, can paste in into browser and see results. Couple of time I got "time limit exceeded" error, not sure if there is anything I can do about that.</p></li>
  <li><p>The problem is that data can be on several pages.Do I have to pick total_pages from page1 and do a loop? Is there a better solution?</p></li>
  </ol>
  
  <p>Here is the code:</p>
  
  <pre><code>string url="https://jsonmock.hackerrank.com/api/movies/search/?Title=spiderman&amp;page=1";
  string res=MakeRequest(url);
  </code></pre>
  
  <p>MakeRequest:</p>
  
  <pre><code>static public string MakeRequest(string url)
  {
  
   HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
      request.ContentType = "application/json; charset=utf-8";
      request.PreAuthenticate = true;
  
   HttpWebResponse response = request.GetResponse() as HttpWebResponse;
      using (Stream responseStream = response.GetResponseStream())
      {
          StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
          return (reader.ReadToEnd());
  
      }
  
  }
  </code></pre>
  
  <p>Here is what the data (page2) looks like</p>
  
  <pre><code>{"page":"2","per_page":10,"total":13,"total_pages":2,"data":[{"Poster":"N/A","Title":"They Call Me Spiderman","Type":"movie","Year":2016,"imdbID":"tt5861236"},{"Poster":"N/A","Title":"The Death of Spiderman","Type":"movie","Year":2015,"imdbID":"tt5921428"},{"Poster":"https://images-na.ssl-images-amazon.com/images/M/MV5BZDlmMGQwYmItNTNmOS00OTNkLTkxNTYtNDM3ZWVlMWUyZDIzXkEyXkFqcGdeQXVyMTA5Mzk5Mw@@._V1_SX300.jpg","Title":"Spiderman in Cannes","Type":"movie","Year":2016,"imdbID":"tt5978586"}]}
  </code></pre>