I am trying to post some info with an ajax request to a webservice I wrote with some json data
Here are the C# parameters the method receiving it uses
public bool AdvancedIWant(string WantTitle,
int WantCategory,
string WantBlogID,
float WantPrice,
string WantComments)
When I go to the asmx control directly and enter in the values it works fine so it is something with my json format I am guessing…
I used firebug to look at the ajax headers and I got this under post
JSON WantComments “sdfa” Source
{“WantTitle”: “sdfs”},
{“WantCategory”: 1}, {“WantBlog”:
“FCA184D9-9F50-473F-922D-04E0EE004AB8”},
{“WantPrice”: 5.55}, {“WantComments”:
“sdfa”}
this under response
{“Message”:”Invalid JSON primitive:
{\”WantCategory\”: 1}, {\”WantBlog\”:
\”FCA184D9-9F50-473F-922D-04E0EE004AB8\”},
{\”WantPrice\”: 5.55},
{\”WantComments\”:
\”sdfa\”}.”,”StackTrace”:” 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”}
I am guessin my json format is invalid?? I’m not sure maybe I am just missing something at 2 am.
Shouldn’t your post to server be like this:
Compare above with your JSON. I feel you have constructed your JSON in wrong format.
Further watch out for
WantBlog, in service your parameter saysWantBlogId.