<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: ASMX ScriptService mistake &#8211; Invalid JSON primitive</title>
	<atom:link href="http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/feed/" rel="self" type="application/rss+xml" />
	<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/</link>
	<description>ASP.NET and AJAX code, ideas, and examples.</description>
	<lastBuildDate>Thu, 02 Feb 2012 19:50:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: piyush</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-56108</link>
		<dc:creator>piyush</dc:creator>
		<pubDate>Thu, 22 Dec 2011 21:48:43 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-56108</guid>
		<description>Yup, this was helpful and I was stuck with same error too. 

One more thing I would like to add is - 

My webservice had method like AddCustomer(Customer customer).

Assume Customer class has { Name, Address, City } properties, from javascript we need following type of json string.
{&quot;customer&quot;:{&quot;Name&quot;:&quot;A&quot;,&quot;Address&quot;:&quot;123, test drive&quot;,&quot;City&quot;:&quot;Troy&quot;}}

Please note that the parameter-name of the method has to be available in the json string.</description>
		<content:encoded><![CDATA[<p>Yup, this was helpful and I was stuck with same error too. </p>
<p>One more thing I would like to add is &#8211; </p>
<p>My webservice had method like AddCustomer(Customer customer).</p>
<p>Assume Customer class has { Name, Address, City } properties, from javascript we need following type of json string.<br />
{&#8220;customer&#8221;:{&#8220;Name&#8221;:&#8221;A&#8221;,&#8221;Address&#8221;:&#8221;123, test drive&#8221;,&#8221;City&#8221;:&#8221;Troy&#8221;}}</p>
<p>Please note that the parameter-name of the method has to be available in the json string.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-53867</link>
		<dc:creator>Josh</dc:creator>
		<pubDate>Wed, 14 Dec 2011 20:13:33 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-53867</guid>
		<description>Dave,

I think that I understand now, thanks to your post, what&#039;s going on, and I have control over my own data being posted, but is there any way to wrap all data in quotes before sending?  I don&#039;t have any control over the many jquery libraries/plugins that I use, and they all seem to send without quotes, causing this Invalid JSON primitive.

I&#039;ve read a number of your posts, including the one where you use ajaxSetup to set defaults for everything, I&#039;m guessing something in there would be able to format the request correctly first.</description>
		<content:encoded><![CDATA[<p>Dave,</p>
<p>I think that I understand now, thanks to your post, what&#8217;s going on, and I have control over my own data being posted, but is there any way to wrap all data in quotes before sending?  I don&#8217;t have any control over the many jquery libraries/plugins that I use, and they all seem to send without quotes, causing this Invalid JSON primitive.</p>
<p>I&#8217;ve read a number of your posts, including the one where you use ajaxSetup to set defaults for everything, I&#8217;m guessing something in there would be able to format the request correctly first.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roj</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-46727</link>
		<dc:creator>Roj</dc:creator>
		<pubDate>Fri, 21 Oct 2011 20:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-46727</guid>
		<description>This was exactly what I needed, thanks so much!!</description>
		<content:encoded><![CDATA[<p>This was exactly what I needed, thanks so much!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dilip</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-46692</link>
		<dc:creator>Dilip</dc:creator>
		<pubDate>Fri, 21 Oct 2011 03:58:51 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-46692</guid>
		<description>Great clarification ! Hats off !</description>
		<content:encoded><![CDATA[<p>Great clarification ! Hats off !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-46477</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Thu, 13 Oct 2011 09:46:18 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-46477</guid>
		<description>And thanks Dave for original article, great stuff</description>
		<content:encoded><![CDATA[<p>And thanks Dave for original article, great stuff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-46476</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Thu, 13 Oct 2011 09:45:12 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-46476</guid>
		<description>Thanks John, 

Your final comment saved me from going mad, I was trying every variation of parameters and thought from previous comments that GET was not allowed even though UseHttpGet=true is there for all to see, I had simply missed enclosing quotes on a given string, for anyone else -

var getparameters = &quot;searchstr=&#039;&quot; + searchtext + &quot;&#039;&amp;maxresults=&quot; + showmaxresults + &quot;&amp;localservice=&quot; + localcall;
    
    $.ajax({
        type: &quot;GET&quot;,
        data: getparameters,
        url: &quot;http ... your.asmx/ABC&quot;,
        contentType: &quot;application/json; charset=utf-8&quot;,
        dataType: &quot;json&quot;,
        

... etc</description>
		<content:encoded><![CDATA[<p>Thanks John, </p>
<p>Your final comment saved me from going mad, I was trying every variation of parameters and thought from previous comments that GET was not allowed even though UseHttpGet=true is there for all to see, I had simply missed enclosing quotes on a given string, for anyone else -</p>
<p>var getparameters = &#8220;searchstr=&#8217;&#8221; + searchtext + &#8220;&#8216;&amp;maxresults=&#8221; + showmaxresults + &#8220;&amp;localservice=&#8221; + localcall;</p>
<p>    $.ajax({<br />
        type: &#8220;GET&#8221;,<br />
        data: getparameters,<br />
        url: &#8220;http &#8230; your.asmx/ABC&#8221;,<br />
        contentType: &#8220;application/json; charset=utf-8&#8243;,<br />
        dataType: &#8220;json&#8221;,</p>
<p>&#8230; etc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: miguel</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-44591</link>
		<dc:creator>miguel</dc:creator>
		<pubDate>Tue, 09 Aug 2011 03:22:59 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-44591</guid>
		<description>you saved my ass!! thank for this most helpful explanation.
Miguel</description>
		<content:encoded><![CDATA[<p>you saved my ass!! thank for this most helpful explanation.<br />
Miguel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rafael M</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-43619</link>
		<dc:creator>Rafael M</dc:creator>
		<pubDate>Sun, 12 Jun 2011 13:41:13 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-43619</guid>
		<description>Thank you so much, this error cost me like 6 hours...</description>
		<content:encoded><![CDATA[<p>Thank you so much, this error cost me like 6 hours&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chinvar</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-43348</link>
		<dc:creator>chinvar</dc:creator>
		<pubDate>Wed, 11 May 2011 19:50:37 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-43348</guid>
		<description>Thanks a lot, it worked for me. But this is quite different; I was using var parameters = &quot;{ccnum:&quot;+ccnum+&quot;}&quot;; which did not worked; i just replaced double quotes by single and it worked. var parameters = &#039;{ccnum:&quot;+ccnum+&quot;}&#039;;</description>
		<content:encoded><![CDATA[<p>Thanks a lot, it worked for me. But this is quite different; I was using var parameters = &#8220;{ccnum:&#8221;+ccnum+&#8221;}&#8221;; which did not worked; i just replaced double quotes by single and it worked. var parameters = &#8216;{ccnum:&#8221;+ccnum+&#8221;}&#8217;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-43347</link>
		<dc:creator>John</dc:creator>
		<pubDate>Wed, 11 May 2011 13:11:31 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-43347</guid>
		<description>You *can* use GET and query string parameters with ScriptService.  On the server side, it transforms the query string into JSON and so the parameters must be JSON encoded.  E.g. /foo.asmx?intParam=1&amp;stringParam=&#039;foo&#039; -- or %22foo%22.  An &quot;Invalid JSON primitive&quot; exception is thrown for unquoted strings.</description>
		<content:encoded><![CDATA[<p>You *can* use GET and query string parameters with ScriptService.  On the server side, it transforms the query string into JSON and so the parameters must be JSON encoded.  E.g. /foo.asmx?intParam=1&amp;stringParam=&#8217;foo&#8217; &#8212; or %22foo%22.  An &#8220;Invalid JSON primitive&#8221; exception is thrown for unquoted strings.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-42857</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Thu, 31 Mar 2011 21:45:35 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-42857</guid>
		<description>Thanks! This post saved me a lot of head scratching :)</description>
		<content:encoded><![CDATA[<p>Thanks! This post saved me a lot of head scratching :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sangam Uprety</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-42789</link>
		<dc:creator>Sangam Uprety</dc:creator>
		<pubDate>Sat, 26 Mar 2011 02:42:57 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-42789</guid>
		<description>With normal examples set out elsewhere, I won&#039;t get this error since I am aware enough to supply data-value pair into data. But I stumbled when I was trying to get with YUI jsTree. They pass it somehow different leading the above mentioned error. Thanks you.</description>
		<content:encoded><![CDATA[<p>With normal examples set out elsewhere, I won&#8217;t get this error since I am aware enough to supply data-value pair into data. But I stumbled when I was trying to get with YUI jsTree. They pass it somehow different leading the above mentioned error. Thanks you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hector Minaya</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-42044</link>
		<dc:creator>Hector Minaya</dc:creator>
		<pubDate>Mon, 07 Feb 2011 02:00:27 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-42044</guid>
		<description>NIce,

I went through this some time ago and this post helped me get a grip on things...</description>
		<content:encoded><![CDATA[<p>NIce,</p>
<p>I went through this some time ago and this post helped me get a grip on things&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olan</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-42002</link>
		<dc:creator>Olan</dc:creator>
		<pubDate>Fri, 04 Feb 2011 01:09:56 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-42002</guid>
		<description>Dave,
    I am new to JQuery and I am finding out very quickly that debugging someone&#039;s code that involves this technology is very difficult. Thanks for the post!</description>
		<content:encoded><![CDATA[<p>Dave,<br />
    I am new to JQuery and I am finding out very quickly that debugging someone&#8217;s code that involves this technology is very difficult. Thanks for the post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/#comment-41994</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Thu, 03 Feb 2011 16:19:56 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=998#comment-41994</guid>
		<description>I definitely will.  I still have a few more posts in mind for this series.</description>
		<content:encoded><![CDATA[<p>I definitely will.  I still have a few more posts in mind for this series.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

