I have this cURL that works fine running from terminal but I need it to be dynamic so I need to make this call from my model.
curl -XPUT -H "content-type:application/json" http://localhost:8098/riak/demo2 -d '{"props":{"precommit":[{"mod":"riak_search_kv_hook","fun":"precommit"}]}}'
This is what I get so far but it is not working, there are no errors and the response is empty. I don't expect anything to be returned, but this should create a new Riak
bucket and it doesn't. I have tested, as I said, on my terminal and it works fine, it creates the bucket as expected.
require "net/http"
require "uri"
uri = URI.parse("http://localhost:8098/riak/dg1_logs")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
request.content_type = "application/json"
request.body = '{"props":{"precommit":[{"mod":"riak_search_kv_hook","fun":"precommit"}]}}'
response = http.request(request)
p response.body
More details
I'm using Riak
and I need to enable the Riak Search
on my client bucket and it is possible only running this cURL. I need to make it dynamic so when my client creates a new account, I already make his buckets able to Search
I'm using Ruby 1.9.3