Your content type is

  Content-Type: application/x-www-form-urlencoded

... which is wrong, it's application/json.  With the content type you
give, the form body gets parsed as query parameters, and isn't
available as JSON content.

-- Adam Winer

On Sat, Mar 7, 2009 at 11:52 PM, Chirag Shah <[email protected]> wrote:
> I seem to be getting "Could not convert  to class java.util.HashMap" when
> updating appData when the content-type is
> "application/x-www-form-urlencoded" on the latest 1.0.x-incubating build.
>
> I was able to track the issue down to line 99 of AppDataHandler where it
> internally tries to parse an empty postBody into a JSONObject and dies.
> Everything works fine if I change the Content-Type to application/json.
>
> What is the reccomended content-type when a client updates appData? The
> opensocial-php-client uses "Content-Type: application/x-www-form-urlencoded"
> when it wants to update appData.
>
>
> Here's a dump of the request to my server (sandbox.orkut.com gives a similar
> response):
>
> POST
> /social/rest/appdata/@viewer/@self/147810927296?oauth_nonce=nonce&oauth_version=1.0&oauth_timestamp=timestamp&oauth_consumer_key=ck&xoauth_requestor_id=guid&oauth_signature_method=HMAC-SHA1&oauth_signature=signature
> HTTP/1.1^M
> User-Agent: osapi 1.0^M
> Host: snip^M
> Accept: */*^M
> Content-Length: 23^M
> *Content-Type: application/x-www-form-urlencoded^M
> ^M
> {
>  "osapiFoo1":"newBar1"}*
>
> Here is the response:
>  <u>The server encountered an internal error (Unknown error Could not
> convert  to class java.util.HashMap) that prevented it from fulfilling this
> request.</u>
>

Reply via email to