Sounds good! Thanks Adam.  I thought I was missing something because the
opensocial-php-client sets the form body as json content _and_ the content
type as application/x-www-form-urlencoded when updating app data.

I've patched the opensocial-php-client locally to send the correct content
type header and everything works perfectly. (I've been testing my
container's opensocial REST functionality with all the opensocial client
pacakges this weekend.)

Thanks!
Chirag

On Sun, Mar 8, 2009 at 9:09 AM, 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