Note that there are some explanatory texts on larger screens.

plurals
  1. POPost array of strings to web API method
    text
    copied!<p><strong>this is my client side ajax call:</strong></p> <pre><code> var list = ["a", "b", "c", "d"]; var jsonText = { data: list }; $.ajax({ type: "POST", url: "/api/scheduledItemPriceStatus/updateStatusToDelete", data: jsonText, dataType: "json", traditional: true, success: function() { alert("it worked!"); }, failure: function() { alert("not working..."); } }); </code></pre> <p><strong>this is chrome network header:</strong></p> <pre><code>Request URL:http://localhost:2538/api/scheduledItemPriceStatus/updateStatusToDelete Request Method:POST Request Headersview source Accept:application/json, text/javascript, */*; q=0.01 Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8 Connection:keep-alive Content-Length:27 Content-Type:application/x-www-form-urlencoded; charset=UTF-8 Host:localhost:2538 Origin:http://localhost:2538 Referer:http://localhost:2538/Pricing/ScheduledItemPrices User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11 X-Requested-With:XMLHttpRequest </code></pre> <p>Form Dataview URL encoded</p> <pre><code>data:a data:b data:c data:d </code></pre> <p><strong>this is my webapi controller method:</strong></p> <pre><code>public HttpResponseMessage UpdateStatusToDelete(string[] data) </code></pre> <p><strong>result:</strong></p> <p>when I debug, the data parameter in UpdateStatusToDelete returns <code>{string[0]}</code> instead of data:a data:b data:c data:d</p> <p>What am I doing wrong? Any help is really appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload