I am trying to invoke DELETE method of ASP.net WEB API from jqGrid. However I get message - "Error Status: 'Method Not Allowed'. Error code: 405".
Below are the details.
JQGrid code-
$("#employeeSalarysGrid").jqGrid('navGrid', '#employeeSalarysPager',
{
add: true,
edit: true,
del: true
},
editOption,
addOption,
delOption);
var delOption = {
caption: "Delete",
msg: "Delete selected record(s)?",
bSubmit: "Delete", bCancel: "Cancel",
mtype: "DELETE",
url: 'http://localhost:50570/api/Test/'
};
ASP.NET Web API method:
public HttpResponseMessage Delete(string id)
{
//code for processing delete request
}
I have traced the request sent using Fiddler. Below is the request details:
DELETE http://localhost:50570/api/Test HTTP/1.1
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://localhost:53055/Views/Test.aspx
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost:50570
Content-Length: 13
Connection: Keep-Alive
Pragma: no-cache
oper=del&id=2
Please note parameter Id=2 is sent in the body of request and not query string, which I believe should be fine.
Please let me know your thoughts on reason why delete method is not getting invoked.