title: c# web api not working as POST Type
body: <p>Below is my API structure</p>
  
  <pre><code> public class CustomController : ApiController
  {
     [HttpPost]
      public DataSet POSTM(string StaffCode, string bytearray, string Reason)
     {
      //Some Business logic Here
     }
  }
  </code></pre>
  
  <p>And its route </p>
  
  <pre><code> config.Routes.MapHttpRoute(
                  name: "DefaultApi2",
                  routeTemplate: "api/{controller}/{staffCode}/{bytearray}/{Reason}",
                  defaults: new {
                      staffCode = RouteParameter.Optional,
                      bytearray = RouteParameter.Optional,
                      Reason = RouteParameter.Optional
  
                  }
              );
  </code></pre>
  
  <p>I am try to invoke it from jquery ajax as </p>
  
  <pre><code>var data = {
              staffCode: staffCode_,
              bytearray: bytearray_,
              Reason: Reason_,
          };
  
          $.ajax(
              { url: 'http://localhost:59118/api/Custom/', 
               method : 'POST', 
               dataType: 'JSON', 
               data:data, 
               success: function (d) 
               { 
                   alert("Saved Successfully"); 
  
               }, 
               error: function (e) 
               { 
                   alert("Error please try again"); 
               } 
              });
  </code></pre>
  
  <p>After invoking it I am getting 500 Internal Server Error in console Log</p>
  
  <p>But if I changed [HttpPost] to [HttpGet]  than it works perfectly fine </p>
  
  <p>Why it is not working as POST ?</p>