My Big Ol’ JSON Rest mistake

This was really kicking my bahonkus. I’ve created a JSON RESTful service using WCF and my “get” calls were working like a clock.  But, every time I made a “post” request I got the same error: “Encountered unexpected character ‘x’”.  I spent a day and a half trying to fix it by changing my behaviors and modifying the WebEnvoke attribute…  Then I stumbled across this blog post:
http://encosia.com/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/

And all my problems were caused by the third mistake he lists: JQuery will URL-encode the data. As it turns out, the xml parser that handles these requests does not care for the encoding, and will throw a super cryptic error. And searching for JSON REST WCF errors will give you a lot of results, but none that answer this question. Ah abstraction, you fickle mistress…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s