带有多参数的WCF RESTFull apis的Ajax POST请求404错误

时间:2015-12-28 14:19:10

标签: jquery ajax wcf

我正在编写Ajax POST多参数请求来获取一些数据。我收到404错误。

以下是Ajax请求

   var ServerAuthKey = {};
   ServerAuthKey.UserID = localStorage.getItem("SessionUserID");
   ServerAuthKey.SessionID = localStorage.getItem("SessionID");
   ServerAuthKey.Result = true;
    openBusyIndicator();
    $.ajax({
        type: "POST",
        url: ConnectionString+"/GetServerData.svc/FetchSelectedDiagDetails",
        contentType: "application/json; charset=utf-8",
        data:JSON.stringify({clientAuthKey:ServerAuthKey,sUserID:loginDetailsObj.getUserName(),StartOffset:startDiagOffset.toString(),EndOffset:EndDiagOffset.toString() }),
        dataType: "json",
        success: populateData,
           error: fetcherror,

    });

以下是服务器端的WCF REST apis实现

[OperationContract]
    [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, UriTemplate = "FetchSelectedDiagDetails/{sUserID}/{StartOffset}/{EndOffset}", BodyStyle = WebMessageBodyStyle.Wrapped)]
    List<Diag_tblData> FetchSelectedDiagDetails(AuthenticationKey clientAuthKey, string sUserID, string StartOffset, string EndOffset); 

以下是请求字符串

{"clientAuthKey":{"UserID":"riya","SessionID":"riyariya12282015183957","Result":true},"sUserID":"riya","StartOffset":"1","EndOffset":"20"}

任何人都可以帮我找出问题吗?

1 个答案:

答案 0 :(得分:0)

Http 404响应意味着找不到文件。

要检查的第一件事是您的变量“ConnectionString”设置正确。