title: Error: InvalidOperationException: The model item passed into the ViewDataDictionary is of type
body: <p>I have a problem, every time I run my application it gives this error below. I debugged it line by line and saw that the error opens when executing the line &quot;var res = await client.SendAsync(req);&quot;</p>
  <p>I've tried everything and I can't find a solution. I've searched everywhere, I've changed from &quot;SendAsync&quot; to everything possible and I can't solve it, I've been trying for 2 days.</p>
  <p><strong>My code:</strong></p>
  <pre><code>public async Task ListAsync()
          {
              var client = new HttpClient
              {
                  BaseAddress = new Uri(&quot;https://teste.teste1.com.br&quot;)
              };
  
              client.DefaultRequestHeaders.Add(&quot;x-user-email&quot;, &quot;victor@teste.com.br&quot;);
              client.DefaultRequestHeaders.Add(&quot;x-api-key&quot;, &quot;eyJ0eXAiOiJKV1QiLCJhbGcxYg&quot;);
              client.DefaultRequestHeaders.Add(&quot;x-store-key&quot;, &quot;1&quot;);
              client.DefaultRequestHeaders.Add(&quot;accept&quot;, &quot;application/json;charset=UTF-8&quot;);
             // client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(&quot;application/json&quot;));
  
              HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, &quot;/app/Api/V1/Products/list&quot;);
              req.Content = new StringContent(&quot;Content-Type&quot;, Encoding.UTF8, &quot;application/json&quot;);
              using var res = await client.SendAsync(req);
              res.EnsureSuccessStatusCode();
              var responseBody = await res.Content.ReadAsStringAsync();
              var root = JsonSerializer.Deserialize&lt;Product&gt;(responseBody);
          }
  </code></pre>
  <p><strong>My index(view):</strong></p>
  <pre><code>@model IEnumerable&lt;WebConsumoApi.Models.Product&gt;
  
  @{
      ViewData[&quot;Title&quot;] = &quot;Index&quot;;
  }
  
  &lt;h1&gt;Index&lt;/h1&gt;
  
  &lt;p&gt;
      &lt;a asp-action=&quot;Create&quot;&gt;Create New&lt;/a&gt;
  &lt;/p&gt;
  &lt;table class=&quot;table&quot;&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.sku)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.name)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.description)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.status)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.qty)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.price)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.list_price)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.weight_gross)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.weight_liquid)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.height)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.width)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.length)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.items_per_package)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.brand)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.ean)
              &lt;/th&gt;
              &lt;th&gt;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
  @foreach (var item in Model) {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.sku)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.name)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.description)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.status)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.qty)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.price)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.list_price)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.weight_gross)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.weight_liquid)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.height)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.width)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.length)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.items_per_package)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.brand)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.ean)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.ActionLink(&quot;Edit&quot;, &quot;Edit&quot;, new { id = item.sku }) |
                  @Html.ActionLink(&quot;Details&quot;, &quot;Details&quot;, new { id = item.sku }) |
                  @Html.ActionLink(&quot;Delete&quot;, &quot;Delete&quot;, new { id = item.sku })
              &lt;/td&gt;
          &lt;/tr&gt;
  }
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  <p><strong>My Interface:</strong></p>
  <pre><code>using WebConsumoApi.Models;
  
  namespace WebConsumoApi.Interfaces
  {
      public interface IProduto
      {
          Task ListAsync();
          Product Create(Product produto);
          Product Update(Product produto);
          Product GetOne(string Codigo);
          Product Delete(string Codigo);
  
      }
  }
  </code></pre>
  <p><strong>EDIT 1:</strong></p>
  <p>ERROR: <a href="https://i.stack.imgur.com/pOzUR.png" rel="nofollow noreferrer">ERRO</a></p>
  <p><strong>EDIT 2(CONTROLLER):</strong></p>
  <pre><code>using Microsoft.AspNetCore.Http;
  using Microsoft.AspNetCore.Mvc;
  using WebConsumoApi.Interfaces;
  using WebConsumoApi.Models;
  
  namespace WebConsumoApi.Controllers
  {
      public class ProdutosController : Controller
      {
          private readonly IProduto _IProduto;
          public ProdutosController(IProduto IProduto)
          {
              _IProduto = IProduto;
          }
  
          // GET: ProdutosController
          public async Task&lt;ActionResult&gt; Index()
          {
              return View(_IProduto.ListAsync());
          }
  
          // GET: ProdutosController/Details/5
          public ActionResult Details(string id)
          {
              return View(_IProduto.GetOne(id));
          }
  
          // GET: ProdutosController/Create
          public ActionResult Create()
          {
              return View();
          }
  
          // POST: ProdutosController/Create
          [HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult Create(Product collection)
          {
              try
              {
                  _IProduto.Create(collection);
                  return RedirectToAction(nameof(Index));
              }
              catch
              {
                  return View();
              }
          }
  
          // GET: ProdutosController/Edit/5
          public ActionResult Edit(string id)
          {
              return View(_IProduto.GetOne(id));
          }
  
          // POST: ProdutosController/Edit/5
          [HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult Edit(int id, Product collection)
          {
              try
              {
                  _IProduto.Update(collection);
                  return RedirectToAction(nameof(Index));
              }
              catch
              {
                  return View();
              }
          }
  
          // GET: ProdutosController/Delete/5
          public ActionResult Delete(string id)
          {
              return View(_IProduto.GetOne(id));
          }
  
          // POST: ProdutosController/Delete/5
          [HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult Delete(string id, Product collection)
          {
              try
              {
                  _IProduto.Delete(id);
                  return RedirectToAction(nameof(Index));
              }
              catch
              {
                  return View();
              }
          }
      }
  }
  </code></pre>
  <p><strong>My class Product:</strong></p>
  <pre><code>namespace WebConsumoApi.Models
  {
  
      public class Product
      {
          public string sku { get; set; }
          public string name { get; set; }
          public string description { get; set; }
          public string status { get; set; }
          public int qty { get; set; }
          public float price { get; set; }
          public float? list_price { get; set; }
          public float weight_gross { get; set; }
          public float weight_liquid { get; set; }
          public int height { get; set; }
          public int width { get; set; }
          public int length { get; set; }
          public string items_per_package { get; set; }
          public string brand { get; set; }
          public string ean { get; set; }
          public object ncm { get; set; }
          public Category[] categories { get; set; }
          public string[] variation_attributes { get; set; }
          public Variation[] variations { get; set; }
          public string[] images { get; set; }
          public Published_Marketplace published_marketplace { get; set; }
          public Marketplace_Offer_Links[] marketplace_offer_links { get; set; }
      }
  }
  </code></pre>