title: Insert data through Asp.net web API in sql server database
body: <p>I am trying to insert data using web API. </p>
  
  <p>I have taken empty web application with Web API folder and core references. </p>
  
  <p>My AppModel Class</p>
  
  <pre><code>public class AppModel
  {
      public int RegisterId { get; set; }
      public string RegisterName { get; set; }
      public string RegisterUserName { get; set; }
      public string RegisterPassword { get; set; }
      public string RegisterEmail { get; set; }
      public string RegisterMobile { get; set; }
      public DateTime RegisterDate { get; set; }
      public string RegisterStatus { get; set; }
  }
  </code></pre>
  
  <p>Below is my HomeController code</p>
  
  <pre><code>public class HomeController : ApiController
  {
      SqlConnection xc;
      SqlCommand xcmd;
  
      [HttpPost]
      public string RegisterUser([FromBody] AppModel register)
      {
          try
          {
              using (xc = new SqlConnection(ConfigurationManager.ConnectionStrings["db_appConnectionString"].ConnectionString))
              {
                  xcmd = new SqlCommand("sp_insert_register", xc);
                  xcmd.CommandType = CommandType.StoredProcedure;
                  xcmd.Parameters.AddWithValue("@register_id", register.RegisterId);
                  xcmd.Parameters.AddWithValue("@register_name", register.RegisterName);
                  xcmd.Parameters.AddWithValue("@register_username", register.RegisterUserName);
                  xcmd.Parameters.AddWithValue("@register_password", register.RegisterPassword);
                  xcmd.Parameters.AddWithValue("@register_email", register.RegisterEmail);
                  xcmd.Parameters.AddWithValue("@register_mobile", register.RegisterMobile);
                  xcmd.Parameters.AddWithValue("@register_date", DateTime.Now);
                  xcmd.Parameters.AddWithValue("@register_status", "True");
  
                  xc.Open();
                  int i = xcmd.ExecuteNonQuery();
                  if (i &gt; 0)
                  {
                      msg = "User Registered";
                  }
                  else
                  {
                      msg = "Something went wrong.";
                  }
              }
          }
          catch (Exception ex)
          {
              msg = ex.ToString();
          }
          return msg;
      }
  }
  </code></pre>
  
  <p>I am confused how to pass values to these parameter.I am testing API in Postman.
  I don't what key to pass in Body</p>