That actually isn't spec compliant, is it? Since the spec states that the
default should always be assumed to be 'json'.
With php-shindig it checks to see if it has a recognizable content-type
header, if not it checks for a recognizable format=foo query param, and
otherwise sets the expected input & output formats to 'json', which means in
this case everything works as expected.

No biggy, and i have commit access to the php opensocial client library so
I'll go and update that, however for people who roll their own (or use
different libraries which makes the same assumption) it might be worth it to
change this behavior in my opinion.

   -- Chris

On Sun, Mar 8, 2009 at 5:09 PM, Adam Winer <[email protected]> wrote:

> 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