The get working fine but the get by id using POST or PUT is returning Error 404.
WCF DataService.svc
Public Function GetHealthcare(ByVal CategoryId As String) As vwHealthcare Implements IDataService.GetHealthcare Dim nSubject As New vwHealthcare
Dim context As DataClasses1DataContext = New DataClasses1DataContext()
'Check if exists
Dim res = From b In context.vwHealthcares Where b.CategoryId = CategoryId
Select b
Dim uList As List(Of vwHealthcare) = res.ToList()
Return res
End Function
IDataService
<WebInvoke(Method:="POST", ResponseFormat:=WebMessageFormat.Json, UriTemplate:="GetHealthcareByCategoryId/{CategoryId}")>
<OperationContract()>
Function GetHealthcare(ByVal CategoryId As String) As vwHealthcare
My Client Html :
// Urls to access the WCF Rest service methods
var urlsource ;
urlsource = "http://localhost/ehealthservice/DataService.svc/";
var varType;
var varUrl;
var method;
var varData;
var varContentType;
var varDataType;
var varProcessData;
//Generic function to call AXMX/WCF Service
function CallServiceC() {
debugger;
var categoryid = getQueryStringValue('CategoryId');
var oData;
debugger;
$.ajax({
cache: false,
type: varType, //GET or POST or PUT or DELETE verb
url: varUrl, // Location of the service
data: oData, //Data sent to server
contentType: varContentType, // content type sent to server
crossDomain: true,
dataType: varDataType,
timeout: 2000,
success: function (msg) {//On Successfull service call
debugger;
// I want to get here
return html;
}
},
error: ServiceFailedC// When Service call fails
});
}
function ServiceFailedC(result) {
debugger;
var myJSON = JSON.stringify(result);
alert('Service call failed: ' + result.status + '' + result.statusText);
varType = null; varUrl = null; varData = null; varContentType = null; varDataType = null; varProcessData = null;
}
function GetHealthcareByCategory() {
debugger;
varType = "POST";
varUrl = urlsource + "GetHealthcareByCategoryId/1";
varContentType = "application/json; charset=utf-8";
varDataType = "jsonp";
varProcessData = false;
method = "GetHealthcare";
CallServiceC();
}
function getQueryStringValue(key) {
debugger;
return unescape(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
};
$(document).ready(
function () {
GetHealthcareByCategory();
}
);
Note : I have tried many approach still the same 404 error. I have enabled the read/write permission on the folder too. This sample is following Pranya example with link enter link description here and I still get Error 404 please any dev in the house.