title: How to post parameter from body [FromBody] and retrieve objects in a <list> in WebAPI?
body: <p>How to post parameter to a body and get the object in a list? IO am able to retrieve the data using this post method in my controller with parameter appended to the URI</p>
  
  <p>Accounts controller:</p>
  
  <pre><code>[HttpPost]
  [ActionName("mini")]
  public List&lt;MiniStatement&gt; GetMiniStatement(string accountNumber)
  {
      var miniState = BusinessLayer.Api.AccountHolderApi.GetMiniStatement(accountNumber);
      return miniState.ToList();
  }
  </code></pre>
  
  <p>But how do I pass the parameter <code>[FromBody]</code> and retrieve the data in a list?</p>
  
  <p>MiniStatement class:</p>
  
  <pre><code>public  class MiniStatement
  {
      public string AccountNumber { get; set; }
      public string TranDate { get; set; }
      public string Trans { get; set; }
      public decimal Amount { get; set; }
  }
  </code></pre>
  
  <p><code>GetMiniStatement</code> method in DB layer:</p>
  
  <pre><code>public static List&lt;MiniStatement&gt; GetMiniStatement(string accountNumber)
  {
      List&lt;MiniStatement&gt; resultList = new List&lt;MiniStatement&gt;();
  
      using (var conn = new NpgsqlConnection("Server=localhost;UserId = postgres; " + "Password = pes; Database = pmc;"))
      {
          conn.Open();
  
          using (var command = new NpgsqlCommand("SELECT * FROM sms.dep_mini_statement(@AccountNumber);", conn))
          {
              command.Parameters.AddWithValue("@AccountNumber", accountNumber);
  
              using (var dr = command.ExecuteReader())
              {
                  while (dr.Read())
                  {
                      var result = new MiniStatement
                      {
                          AccountNumber = accountNumber,
                          TranDate = (string)dr[0],
                          Trans = (string)dr[1],
                          Amount = (decimal)dr[2]
                      };
                      resultList.Add(result);
                  }
              }
          }
      }
  
      return resultList;    
  }
  </code></pre>
  
  <p>And the <strong>Route</strong></p>
  
  <pre><code>config.Routes.MapHttpRoute("MobileBankingApi", "v1/{controller}/{action}");
  </code></pre>