title: Api Response as a List / fetching all the data from api response
body: <p>I am new to .netcore mvc architecture. I am trying to consume the api data response, So far I have successfully fetched the data, but the problem I am facing is when the api response/result is more than one. Forexample if the actuall api response is the following</p>
  
  <pre><code>  "responseHeader":{
      "status":0,
      "QTime":0,
      "params":{
        "q":"title:\"A\""}},
    "response":{"numFound":3,"start":0,"docs":[
        {
          "date":"1970-01-01T00:00:00Z",
          "tstamp":"2019-11-22T12:22:31.698Z",
          "digest":"e23d679991d80d832504e7395d139fe4",
          "contentLength":"25476",
          "boost":0.0,
  
         "title":["emb- A1]
          "url":"https://www.example.com/a/b/c0/"},
  {
          "date":"1970-01-01T00:00:00Z",
          "tstamp":"2019-11-22T12:22:31.698Z",
          "digest":"e23d679991d80d832504e7395d139fe4",
          "contentLength":"25476",
          "boost":0.0,
     "title":["emb - A2]
          "url":"https://www.example.com/a/b/c1/"
  },
  {
          "date":"1970-01-01T00:00:00Z",
          "tstamp":"2019-11-22T12:22:31.698Z",
          "digest":"e23d679991d80d832504e7395d139fe4",
          "contentLength":"25476",
          "boost":0.0,
     "title":["emb - A3]
          "url":"https://www.example.com/a/b/c2/"
  }
  
  </code></pre>
  
  <p>I am only getting</p>
  
  <pre><code>{"title":"[\r\n  \"emb- A1","source":"https://www.example.com/a/b/c0/"}
  </code></pre>
  
  <p>instead of having all the response data.</p>
  
  <p>My Code is below. 
  <strong>Model</strong>
  <em>SearchModel.cs</em></p>
  
  <pre><code>
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  
  namespace searchEngineTesting.Models
  {
      public class SearchModel
      {
          public string Title;
          public string Source;
  
      }
  }
  
  
  </code></pre>
  
  <p><strong>Controller</strong>
  <em>EngineController.cs</em></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net.Http;
  using System.Net.Http.Headers;
  using System.Text;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Http;
  using Microsoft.AspNetCore.Mvc;
  using Newtonsoft.Json;
  using Newtonsoft.Json.Linq;
  using searchEngineTesting.Models;
  
  namespace searchEngineTesting.Controllers
  {
      [Route("api/[controller]")]
      [ApiController]
      public class EngineController : ControllerBase {
  
  
          [HttpGet("[action]/{query}")]
          public async Task&lt;IActionResult&gt; Product(string query)
          {
              var model = new SearchModel();
              using (var client = new HttpClient())
              {
                  try
                  {
                      client.BaseAddress = new Uri("http://xx.xx.xxx.xx:8080");
                      var response = await client.GetAsync($"/abc/xxx/select?q=title%3A%22{query}%22");
                      response.EnsureSuccessStatusCode();
                      var stringResult = await response.Content.ReadAsStringAsync();
                      var root = (JObject)JsonConvert.DeserializeObject(stringResult);
                      //var details = JsonConvert.DeserializeObject&lt;SearchModel&gt;(stringResult);
                      var items = root.SelectToken("").Children().OfType&lt;JProperty&gt;().ToDictionary(p =&gt; p.Name, p =&gt; p.Value);
  
                      foreach (var item in items)
                      {
                          if (item.Key == "response")
                          {
                              var key = item.Value.SelectToken("").OfType&lt;JProperty&gt;().ToDictionary(p =&gt; p.Name, p =&gt; p.Value);
  
                              foreach (var k in key)
                              {
                                  if(k.Key == "docs")
                                  {
                                      var tests = JsonConvert.DeserializeObject&lt;JArray&gt;(k.Value.ToString());
                                      var data = k.Value.SelectToken("").Children().First();
                                      var test = data.SelectToken("").Children().OfType&lt;JProperty&gt;().ToDictionary(p =&gt; p.Name, p =&gt; p.Value).ToList();
                                      foreach (var t in test)
                                      {
                                          if (t.Key =="url")
                                          {
                                              model.Source = t.Value.ToString();
                                          }
                                          else if (t.Key == "title")
                                          {
                                              model.Title = t.Value.ToString();                                        }
                                      }
                                  }
                              }
                          }
                      }
  
                      return new JsonResult(model);
  
                  }
                  catch (InvalidOperationException httpreq) {
                      return BadRequest("Sorry: There are no results for your query");
                  }
              }
          }
  
  
  
      }
  }
  </code></pre>
  
  <p>How can I retrieve whole of the response I am getting from actual API.</p>
  
  <p>Please help..! </p>