title: Sending empty array to webapi
body: <p>I want to POST an empty javascript array <code>[]</code> to webAPI and have it create an empty list of integers. I also want it so if I post javascript <code>null</code> to webAPI that it assigns null to the list of integers.</p>
  
  <p>JS:</p>
  
  <pre><code>var intArray = [];
  $.ajax({
      type: 'POST',
      url: '/api/ListOfInts',
      data: {'' : intArray},
      dataType: 'json'
  });
  </code></pre>
  
  <p>c# webapi</p>
  
  <pre><code>[HttpPost]
  public void ListOfInts([FromBody]List&lt;int&gt; input)
  </code></pre>
  
  <p>Problem 1) Jquery refuses to send data <code>{'' : []}</code> as the post payload. As soon as I add something in the array it works such as <code>{'' : [1,2,3]}</code></p>
  
  <p>Problem 2)  <a href="https://stackoverflow.com/questions/23108272/passing-empty-js-array-to-controller-gives-null">Passing empty js array to controller gives null</a> Based on what i read even if I do get it to post an empty array, it will initialize the list as null.  Discussed solutions have it so that the list is always initializes as empty but I don't want that. I want it to be null in some case (when null/undefined is sent to it) and when <code>[]</code> is sent it should initialize as empty.</p>
  
  <p>Edit: See <a href="https://www.asp.net/web-api/overview/advanced/sending-html-form-data-part-1" rel="nofollow noreferrer">https://www.asp.net/web-api/overview/advanced/sending-html-form-data-part-1</a> about why I am using <code>{'' : []}</code></p>