Getting 500 error

Intarojurrino

New Member
I am using JQuery and Ajax to interface with an ASP.Net web service. Here is the Jquery code:\[code\]$.jrpc = function(url, id, method, params, success, error) { var request = $.json_stringify({ 'jsonrpc': '2.0', 'method': method, 'params': params, 'id': id}); return $.ajax({ url: url, data: "json=" + encodeURIComponent(request), success: success, error: error, contentType: 'application/json; charset=utf-8', dataType: 'json', async: true, cache: false, //timeout: 1, type: 'POST'});};\[/code\]Here is the web service code:\[code\][WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][ScriptService]public class Access : System.Web.Services.WebService{ [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string EntryMethod(string json) { Requests d = JsonConvert.DeserializeObject<Requests>(json); Response resp = new Response(); resp.jsonrpc = d.jsonrpc; resp.result = "Got the call!"; resp.id = d.id; resp.error = null; JavaScriptSerializer response = new JavaScriptSerializer(); string r = response.Serialize(resp); return r; }}\[/code\]I am getting this error:[AJAX] error - Server reponse is: {"Message":"Invalid JSON primitive: json.","StackTrace":" at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}Using the ASP.Net webservice test page, here are my headers and request string:Cache-Control: private, max-age=0Date: Wed, 03 Oct 2012 19:47:16 GMTContent-Length: 149Content-Type: text/xml; charset=utf-8Server: ASP.NET Development Server/10.0.0.0X-AspNet-Version: 4.0.30319Connection: Closejson=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22test%22%2C%22params%22%3A%5B%5D%2C%22id%22%3A1%7DAnd here are the headers/request string of my Ajax call which is not working:Cache-Control: privateDate: Wed, 03 Oct 2012 19:47:09 GMTContent-Length: 1062Content-Type: application/json; charset=utf-8jsonerror: trueServer: ASP.NET Development Server/10.0.0.0X-AspNet-Version: 4.0.30319Connection: Closejson=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22test%22%2C%22params%22%3A%5B%5D%2C%22id%22%3A1%7DAny ideas as to why I am getting this error? I've tried googling it, but none of the results have really helped me.Edit:If I use: data: "{'jsonrpc':'2.0','method':'test','params':[],'id':1}",I get this error:[AJAX] error - Server reponse is: {"Message":"Invalid web service call, missing value for parameter: \u0027json\u0027.","StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary\[code\]2 parameters)\r\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary\[/code\]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"}If I use: data: "json={'jsonrpc':'2.0','method':'test','params':[],'id':1}",I get this error:[AJAX] error - Server reponse is: {"Message":"Invalid JSON primitive: json.","StackTrace":" at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}
 
Back
Top