From user-return-5717-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Thu Jul 30 09:07:57 2009 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 84070 invoked from network); 30 Jul 2009 09:07:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Jul 2009 09:07:55 -0000 Received: (qmail 35899 invoked by uid 500); 30 Jul 2009 09:07:54 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 35818 invoked by uid 500); 30 Jul 2009 09:07:54 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 35808 invoked by uid 99); 30 Jul 2009 09:07:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jul 2009 09:07:54 +0000 X-ASF-Spam-Status: No, hits=3.7 required=10.0 tests=HTML_MESSAGE,NORMAL_HTTP_TO_IP,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mattaimonetti@gmail.com designates 209.85.217.209 as permitted sender) Received: from [209.85.217.209] (HELO mail-gx0-f209.google.com) (209.85.217.209) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jul 2009 09:07:44 +0000 Received: by gxk5 with SMTP id 5so1784817gxk.11 for ; Thu, 30 Jul 2009 02:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=p+QBWGERDFyD/ruA7hTL1UXWDRMUVyPwd9+HP/Ki0i8=; b=QU8+/w4H5SUTym04UD5GrbF5xiIRInODIKLZjpN3+vX+ACrk3nrc0d4SCkwfeZOmp0 tmWh6AeM42/d1QDLxx+lsyE5+NSF30dFSoQkD+kHebp2zdFqA7OiqhpqF059n/X4x3vr jxQ4mCyxqNGXjuI6l2soMceLZYKkQm/8oGFgE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=MlWVJYgxVipmNKgjhHXX+r69NDsnPj6MRClcX10t4ZiRpaYZ4qtiAlpbHP1QaNVln5 9KankbYYomOToDtsMtv1+3C/im+WfDmYZiPTH3TcBW0LVG1I/V0ZPLMCwr0Zu2UY0aa0 g3jYUJTUo8GVMuxIexskWpLE9geacK8SQSqXI= MIME-Version: 1.0 Received: by 10.150.215.8 with SMTP id n8mr1737738ybg.41.1248944841000; Thu, 30 Jul 2009 02:07:21 -0700 (PDT) In-Reply-To: References: <55fad2460907230355v5943ab0fmd9abb17b1a073409@mail.gmail.com> <55fad2460907230406q22ba54a6n3238cc064ede06@mail.gmail.com> Date: Thu, 30 Jul 2009 02:07:20 -0700 Message-ID: <20fefa50907300207u5f66e3aax27d74df4eb70fc1d@mail.gmail.com> Subject: Re: Problems with Ruby + Json + CouchDB From: Matt Aimonetti To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=000e0cd59ce09789b2046fe8a13a X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd59ce09789b2046fe8a13a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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/a8c7256974653ae2217cdcac8b72eee0= 371c1a59/lib/couchrest/core/rest_api.rb http://github.com/couchrest/couchrest/blob/a8c7256974653ae2217cdcac8b72eee0= 371c1a59/lib/couchrest/core/adapters/restclient.rb - Matt On Thu, Jul 30, 2009 at 1:08 AM, Nils Breunese 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 [manolopm@gmail.com] > Verzonden: donderdag 23 juli 2009 13:06 > Aan: user@couchdb.apache.org > 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 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 =3D ["603be1d626a743345cf58a55c2f0d6ed"] > > > > req =3D Net::HTTP::Post.new(' > http://127.0.0.1:5984/fisica-nist2/_all_docs?include_docs=3Dtrue') > > req["content-type"] =3D "application/json" > > req.body =3D JSON.generate(id) > > > > res =3D 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=C3=B3n Mart=C3=ADnez > > > > De informatie vervat in deze e-mail en meegezonden bijlagen is uitsluite= nd > bedoeld voor gebruik door de geadresseerde en kan vertrouwelijke informat= ie > bevatten. Openbaarmaking, vermenigvuldiging, verspreiding en/of verstrekk= ing > 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. > --000e0cd59ce09789b2046fe8a13a--