Am I using the riak http interface wrong?

Bryan Fink bryan at basho.com
Wed Jan 6 14:45:22 EST 2010


On Wed, Jan 6, 2010 at 1:25 PM, Matthew Curry <mjcurry at gmail.com> wrote:
> Hello all:
>
> I'm exploring different of these "nosql" map/reduce datastores, and
> riak looks promising.  So I'm following along in the README, and I've
> had a few problems.
>
> First, there are some typos in the README, mainly that I had to
> binary-ize the strings (e.g. "groceries" should be <<"groceries">>
> etc.), hg diff attached.
>
> Second, after I managed to get through the README example, I pointed
> telnet at the server to issue a GET request to pull out the value of
> the key, and I get a 500 internal server error.  Just doing a GET
> request on the bucket (not giving a key) seems to work.  My session is
> below.
> Anyone know what the error message means?  I can see the value
> ["bread"] in the error response body, however, for some reason the
> conversion from riak_object to jiak_object seems to fail, judging from
> the stack trace.
>
> -Matt


Hi, Matt.  Thanks for the README patches.  I'll apply them shortly.

As for the HTTP errors, the problem is that the Jiak interface stores
a specific shape of value in the Riak object, and the objects created
by the examples in the README don't match that shape.  To get the
correct shape, it's best to use PUT (or POST) requests to store the
objects through the HTTP layer before retrieving them with GET.

The Jiak interface (exposed at /jiak/Bucket/Key) will expect all of
your data to be JSON of a specific form.  If you'd rather use your own
JSON structure, or any other format (e.g. plain text, html, binary
data), use the "raw" HTTP interface (exposed at /raw/Bucket/Key).  The
comments at the top of raw_http_resource.erl explain a little bit more
about the headers/etc. used in those requests.

http://hg.basho.com/riak/src/tip/apps/riak/src/raw_http_resource.erl

Hope that helps,
Bryan




More information about the riak-users mailing list