Manolo, it's because you need to encode your payload when you do a POST. Check how we do it in CouchRest:
http://github.com/couchrest/couchrest/blob/a8c7256974653ae2217cdcac8b72eee0371c1a59/lib/couchrest/core/rest_api.rb http://github.com/couchrest/couchrest/blob/a8c7256974653ae2217cdcac8b72eee0371c1a59/lib/couchrest/core/adapters/restclient.rb - Matt On Thu, Jul 30, 2009 at 1:08 AM, Nils Breunese <[email protected]> wrote: > If you're using Ruby, you could also take a look at using a library like > CouchRest: http://groups.google.com/group/couchrest > > Nils Breunese. > ________________________________________ > Van: Manolo Padron Martinez [[email protected]] > Verzonden: donderdag 23 juli 2009 13:06 > Aan: [email protected] > Onderwerp: Re: Problems with Ruby + Json + CouchDB > > I answer myself. I'm a monkey. I was not generating an JSON object > with the property keys, and I forget that I'm doing that in JS because > I was using jquery.couch.js to do that. > > > On Thu, Jul 23, 2009 at 11:55 AM, Manolo Padron > Martinez<[email protected]> wrote: > > Hi: > > > > I'm trying to get some documents with the body from CouchDB, I've try > > to do it JavaScript and no problem but when I try it in Ruby: > > > > > > require 'rubygems' > > require 'json' > > require 'net/http' > > > > id = ["603be1d626a743345cf58a55c2f0d6ed"] > > > > req = Net::HTTP::Post.new(' > http://127.0.0.1:5984/fisica-nist2/_all_docs?include_docs=true') > > req["content-type"] = "application/json" > > req.body = JSON.generate(id) > > > > res = Net::HTTP.start('127.0.0.1', '5984'){|http| > > http.request(req) > > } > > > > I always get an 400 {"error":"bad_request","reason":"Request body must > > be a JSON object"} > > > > Any idea? > > > > Regards from Canary Islands > > > > Manuel Padrón Martínez > > > > De informatie vervat in deze e-mail en meegezonden bijlagen is uitsluitend > bedoeld voor gebruik door de geadresseerde en kan vertrouwelijke informatie > bevatten. Openbaarmaking, vermenigvuldiging, verspreiding en/of verstrekking > van deze informatie aan derden is voorbehouden aan geadresseerde. De VPRO > staat niet in voor de juiste en volledige overbrenging van de inhoud van een > verzonden e-mail, noch voor tijdige ontvangst daarvan. >
