title: Using Jquery Datables with MVC web api, getting 404 error?
body: <p>When I tried to call my web-api from Jquery Datatables, I got a 404 Not Found exception:</p>
  
  <p>My Request URL:</p>
  
  <pre><code>http://someurl/API/LeaveRequest?sEcho=1&amp;iColumns=13&amp;sColumns=FirstName%2CFirstName%2CLastName%2CContactTypeDesc%2CTitle%2CPhone%2CEmail%2CFirstName%2CFirstName%2CLastName%2CContactTypeDesc%2CTitle%2CEmail&amp;iDisplayStart=0&amp;iDisplayLength=10&amp;mDataProp_0=0&amp;mDataProp_1=1&amp;mDataProp_2=2&amp;mDataProp_3=3&amp;mDataProp_4=4&amp;mDataProp_5=5&amp;mDataProp_6=6&amp;mDataProp_7=7&amp;mDataProp_8=8&amp;mDataProp_9=9&amp;mDataProp_10=10&amp;mDataProp_11=11&amp;mDataProp_12=12&amp;iSortCol_0=0&amp;sSortDir_0=asc&amp;iSortingCols=1&amp;bSortable_0=true&amp;bSortable_1=true&amp;bSortable_2=true&amp;bSortable_3=true&amp;bSortable_4=true&amp;bSortable_5=true&amp;bSortable_6=true&amp;bSortable_7=true&amp;bSortable_8=true&amp;bSortable_9=true&amp;bSortable_10=true&amp;bSortable_11=true&amp;bSortable_12=true&amp;userId=0
  </code></pre>
  
  <p>When I put the url into the browser, I got "No HTTP resource was found that matches the request URI"?</p>
  
  <p>I tried a simple Get call with one parameter:</p>
  
  <pre><code>http://someurl/API/LeaveRequest/1
  </code></pre>
  
  <p>I have no issues with this. But not sure how to format multiple parameters from datatables.</p>
  
  <p>My client Code is as follows:</p>
  
  <pre><code> function DisplayLeaveRequests() {
          var oTable = $('#leaveList').dataTable({
              "bServerSide": true,
              "sAjaxSource": "/API/LeaveRequest",
              "fnServerData": function (sSource, aoData, fnCallback) {
                  $.ajax({
                      "dataType": 'json',
                      "type": "GET", 
                      "url": sSource,
                      "data": aoData,
                      "success": fnCallback,
                      "error": handleAjaxException // this sets up jQuery to give me errors
                  });
  
              },
              "oLanguage": { "sZeroRecords": "No requests available", "sEmptyTable": "No requests available" },
              "fnServerParams": function (aoData) {
                  aoData.push({ "name": "userId", "value": 0 }
                  );
              },
              "bProcessing": true,
              "bDeferRender": true,
              "iDisplayLength": 10,
              "bLengthChange": false,
              "bDestroy": true,
              "bFilter": false,
              "aoColumns": [
                          { "sName": "FirstName" },
                          { "sName": "FirstName" },
                          { "sName": "LastName" },
                          { "sName": "ContactTypeDesc" },
                          { "sName": "Title" },
                          { "sName": "Phone" },
                          { "sName": "Email" },
                          { "sName": "FirstName" },
                          { "sName": "FirstName" },
                          { "sName": "LastName" },
                          { "sName": "ContactTypeDesc" },
                          { "sName": "Title" },
                          { "sName": "Email" }
                      ],
              "sPaginationType": "full_numbers"
          });
      }
  </code></pre>
  
  <p>My web api (LeaveRequestController.cs) code:  </p>
  
  <pre><code>public class LeaveRequestController : ApiController
      {
          // GET api/&lt;controller&gt;
          public string Get(int? iDisplayStart,
                                    int iDisplayLength,
                                    string sSearch,
                                    string filterColumn,
                                    string filterSelection,
                                    bool bEscapeRegex,
                                    int iColumns,
                                    int iSortingCols,
                                    int iSortCol_0,
                                    string sSortDir_0,
                                    int sEcho,
                                    int userId)
          {
              RequestRepository rep = new RequestRepository();
              IEnumerable&lt;LeaveRequest&gt; requests = rep.Get().ToList();
  
              var json = from a in requests
                         select ConvertProperty.Convert(new
                         {
                              a.LeaveID,
                              a.FirstName,
                              a.LastName,
                              a.EOD,
               ....etc.....
  </code></pre>