I'm trying to send the string File
to my asmx service and I keep getting the following error:
Message: Invalid web service call, missing value for parameter: File
StackTrace
at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters) at
System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\\r\\n at
System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\\r\\n at
System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)\",\"ExceptionType\":\"System.InvalidOperationException\"}
Here's the JS
function AJAXActionPostData(service, operation, File, callback, async)
{
if (!async) { async = false; }
$.ajax({
type: 'POST',
url: '/API/Service.asmx/operation',
contentType: 'application/json; charset=utf-8',
async: async,
data: "{ 'File': '" + File + "' }",
dataType: 'json',
success: function (msg) { if (msg) { callback(msg.d); } },
error: ErrorHandler
});
}
when passed into the function above file
has a value of "test\r\n" Could the escape characters be messing with it?
Service code
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public bool UploadCSV(string id, string File)
{
string testfile = File;
return true;
}
No other errors are thrown, just the File
not having a value.
I've tried various things but cannot understand what I'm missing?