The Accept header indicates what content-type your client is able to handle. When you specify "application/json" in the Accept header you are telling Riak to return the object if it's content-type is "application/json" otherwise return 406. http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7
Thanks, Dan Daniel Reverri Developer Advocate Basho Technologies, Inc. [email protected] On Thu, Aug 11, 2011 at 1:32 PM, Jonathan Langevin < [email protected]> wrote: > I believe the Accept parameter is intended only for the ability to list > riak-native data. So to get riak parameters back as json, that's when you > specify the Accept header. > Regarding objects that you store it Riak, my experience has been that it > returns the data back as you stored it. So based on the type that you > specify when posting/putting the data, is the content type that you get > back. > > If I'm wrong, hopefully someone will correct me shortly :-) > > <http://www.loomlearning.com/> > * Jonathan Langevin > Systems Administrator > Loom Inc. > Wilmington, NC: (910) 241-0433 - [email protected] - > www.loomlearning.com - Skype: intel352 * > > > > On Thu, Aug 11, 2011 at 12:03 PM, Fyodor Yarochkin > <[email protected]>wrote: > >> Greetings, >> I am probably missing something obvious, but I've been playing with >> it for a couple of days, still can't figure out the consistency and I >> am still a little lost with riak source code so I thought I'd drop a >> line here: >> >> I am experimenting with querying riak data data in different mime >> formats from riak cluster. So for the tests, I am having a piece of >> erlang code, which uses riak-erlang-client, writes some data into riak >> as erlang-binary. >> >> Object = riakc_obj:new(<<"test">>, >> test_util:get_datekey(),{struct, [{field, Value}]}), >> riakc_pb_socket:put(RiakPid, Object), >> >> Now I am trying to make the data to be accessible to non-erlang >> clients so the node.js code (for example) would be able to read it as >> json. >> >> My understanding is that I should be able to specify that I want >> json-formatted data back by adding 'Accept: application/json' header >> (per example here http://wiki.basho.com/HTTP-List-Resources.html) >> >> However I am getting HTTP 406 whenever I am trying to query anything >> but erlang-binary: >> >> srv# curl -i 'http://localhost:8098/riak/test/2011811234248' >> HTTP/1.1 200 OK >> X-Riak-Vclock: a85hYGBgymDKBVIsLC6FEzKYEhnzWBkyincc54MIszUnMfB8v4wskQUA >> Vary: Accept-Encoding >> Server: MochiWeb/1.1 WebMachine/1.7.3 (participate in the frantic) >> Link: </riak/test>; rel="up" >> Last-Modified: Thu, 11 Aug 2011 15:38:16 GMT >> ETag: "6iDf0EKIk76L1KxlXoSB29" >> Date: Thu, 11 Aug 2011 15:33:41 GMT >> Content-Type: application/x-erlang-binary >> Content-Length: 565 >> >> >> However, for application/json >> >> srv# curl -H 'Accept: application/json' -i >> 'http://localhost:8098/riak/test/2011811234248' >> HTTP/1.1 406 Not Acceptable >> Server: MochiWeb/1.1 WebMachine/1.7.3 (participate in the frantic) >> Date: Thu, 11 Aug 2011 15:34:12 GMT >> Content-Length: 0 >> >> >> So, should I store the data as 'json' (json string converted to erlang >> binary) in order to have some uniform data format accessible to erlang >> and non-erlang clients? >> also, how do map-reduce functions work in this case, do they have to >> be strictly erlang in the case of having x-erlang-binary, or the data >> could be converted to json for javascript? >> >> thanks, >> -Fyodor >> >> _______________________________________________ >> riak-users mailing list >> [email protected] >> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com >> > > > _______________________________________________ > riak-users mailing list > [email protected] > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com > >
_______________________________________________ riak-users mailing list [email protected] http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
