I'm having some trouble getting my ruby restclient to do a _bulk_docs
(delete) post correctly
Version: CouchDb 1.1
RestClient 1.6.3
I get a
abstract_response.rb:48:in `return!': 500 Internal Server Error
(RestClient::InternalServerError)
or
abstract_response.rb:48:in `return!': 415 Unsupported Media Type
(RestClient::UnsupportedMediaType)
depending on how I structure my rest client call
############################################
json_resp =
RestClient.get(URI.escape("#{couchdb_url}/#{view_name}"))
resp = JSON.parse(json_resp) unless (json_resp == 'null')
resp['rows'].each do |row|
docs << {'_id' => row['id'], '_rev' => row['key'], '_deleted' =>
"true"}
end
docs_to_send = { 'all_or_nothing' => true, 'docs' => docs }
json_resp =
RestClient.post(URI.escape("#{couchdb_url}/_bulk_docs"),
docs_to_send.to_json, :content_type => :json
)
############################################
I have also tried
json_resp = RestClient.post "#{couchdb_url}/_bulk_docs",
docs_to_send.to_json, :content_type => :json, :accept => :json
json_resp = RestClient.post "#{couchdb_url}/_bulk_docs", { 'docs' => docs,
'all_or_nothing' => true }, :content_type => :json
I see couchrest does it like this
CouchRest.post "#{@root}/_bulk_docs", {:docs => docs}
and the restclient docs show this:
RestClient.post "http://example.com/resource", { 'x' => 1 }.to_json,
:content_type => :json, :accept => :json
I also tried :docs instead of 'docs' but to no avail......
Thanks in advance for any help, advice or guidance