Hi Maulkye,

Just off the top of my head, does your JSON looks like this:

    {
        thingy:  "value"
    }

or like this:

    {
        "thingy":  "value"
    }

The former is not valid JSON syntax.  It is valid JavaScript object
literal syntax, but not JSON, which is a _subset_ of object literal
syntax.  The only primitive values (e.g., things you leave out of
quotes) in JSON are false, true, and null.

So if you're not putting quotes around the things on the left, you
might try that to see if it's the problem.  Maybe the MS parser is
being picky.

HTH,
--
T.J. Crowder
tj / crowder software / com

On Sep 4, 1:31 am, Maulkye <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I keep getting this error message (Invalid JSON primitive) when I try
> to call an Ajax.Request with the 'applicatio/json' content type.  I've
> tried formatting the parameters in a variety of ways, but no luck.
> Can anyone help?
>
> Here's what I have:
>
> CLIENT:
>             new Ajax.Request("/myService.asmx/GetComplexData",{
>                 onSuccess: onSuccess,
>                 onFailure: onFailure,
>                 method:"post",
>                 contentType:"application/json; charset=utf-8",
>                 parameters: {s: 'bob'}
>             });
>
> SERVER:
>
>         [WebMethod]
>         public string GetComplexData(string s)
>         {
>             return s;
>         }
>
> Note that other calls are working.  If I remove the content type, this
> woks ok, but it just populates the string parameter with the value of
> "s" from the client.  Additionally, I tried this on the server, but to
> no avail:
>
>         [WebMethod]
>         public string GetComplexData(object s)
>         {
>             return "ok";
>         }
>
> It seems like there's some way I'm supposed to format the parameters
> to make MS.NET happy, but I can't figure out how it is.  The server
> can obviously handle it, because if I use their big fat client library
> it sends json objects over and puts them into a dictionary object
> without a hitch.
>
> If anyone can offer some suggestions of even point in the right
> direction, I would be most appreciative.
>
> Thanks,
> -M
>
> Full Error Message:
> -----------------------------
> {"Message":"Invalid JSON primitive: s.","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"}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to