Can anyone let me know why the below method fails? I am not getting where i am making mistake. Please help
function getListItems(term) {
var caml = "<View><Query><Where><BeginsWith><FieldRef Name=Title/><Value Type='Text'>" + term + "</Value></BeginsWith></Where></Query></View>";
var requestData = { "query": { "__metadata": { "type": "SP.CamlQuery" }, "ViewXml": caml } };
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/getbytitle('SampleList')/Getitems",
method: "POST",
data:requestData,
headers: {
"accept": "application/json; odata=verbose",
"content-type": "application/json; odata=verbose"
},
success: function (data) {
$("#countItem").html("Pass");
},
error: function (data) {
$("#countItem").html("Fail");
}
});
}
Below is the responseText (log)
"{\"error\":{\"code\":\"-1, Microsoft.SharePoint.Client.ClientServiceException\",\"message\":{\"lang\":\"en-US\",\"value\":\"The HTTP method \'GET\' cannot be used to access the resource \'GetItems\'. The operation type of the resource is specified as \'Default\'. Please use correct HTTP method to invoke the resource.\"}}}"
Navaneeth