From user-return-23683-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Thu Feb 28 17:17:34 2013 Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 18D9AECFA for ; Thu, 28 Feb 2013 17:17:34 +0000 (UTC) Received: (qmail 20378 invoked by uid 500); 28 Feb 2013 17:17:32 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 20172 invoked by uid 500); 28 Feb 2013 17:17:32 -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 20140 invoked by uid 99); 28 Feb 2013 17:17:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Feb 2013 17:17:31 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of alex.barbalex@gmail.com designates 74.125.83.41 as permitted sender) Received: from [74.125.83.41] (HELO mail-ee0-f41.google.com) (74.125.83.41) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Feb 2013 17:17:24 +0000 Received: by mail-ee0-f41.google.com with SMTP id c13so1748248eek.0 for ; Thu, 28 Feb 2013 09:17:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=Gvd39at0bFlUniQSqytMb4AJhLHpEfF9rWNxe08jOdk=; b=N1IjM9/5SjHnU0IBKNshpjPgdFB53KjaFwXA+qcafDFCFhHEvOtkOFMbrMWmFyf0Gy xjitDr3vePLguSPtKk2DNEYRWVsh5u0DGhaPhWZ4ErVUjkje0/Bq0J8WszrQwy63ray0 XTwm6AbB0miKawctOsryc6GVs/qngx/7q/Zekh2C/QQCIQDwACzC860x7/g5LH0ysBn4 5937tp2ap42PvGsqI1vfGWyeaIO0iOuDPcudOBFqT7zYcf61nmAmDQOTLd50h1/WBOdj f874UP79jJFRwByFXslqYHLF8JISU9mLnF2QXObNaWXH7K03zvfmefXdDSJ1+mSplxgq GdwA== MIME-Version: 1.0 X-Received: by 10.14.183.198 with SMTP id q46mr18993909eem.1.1362071823975; Thu, 28 Feb 2013 09:17:03 -0800 (PST) Sender: alex.barbalex@gmail.com Received: by 10.223.146.75 with HTTP; Thu, 28 Feb 2013 09:17:03 -0800 (PST) In-Reply-To: References: Date: Thu, 28 Feb 2013 18:17:03 +0100 X-Google-Sender-Auth: _hdBmTLHEWHyFPV5w2xVmplbyww Message-ID: Subject: Re: http equivalent of curl example From: Alexander Gabriel To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=047d7b3441423a2afe04d6cc0f15 X-Virus-Checked: Checked by ClamAV on apache.org --047d7b3441423a2afe04d6cc0f15 Content-Type: text/plain; charset=UTF-8 I am doing this to test it: IdArray = ["84C19013-D320-420D-AE7E-99892AD5106F","84F72B64-7E47-444A-889F-280CF0610555"]; console.log('IdArray = ' + IdArray); var ajax = $.ajax({ type: 'GET', url: $(location).attr("protocol") + '//' + $(location).attr('host') + '/artendb/_all_docs?include_docs=true&keys=[' + IdArray + ']', contentType: "application/json", success: function(data) { console.log('sucess = ' + JSON.stringify(data)); }, error: function(data) { console.log('error = ' + JSON.stringify(data)); } }); the answer is: IdArray = 84C19013-D320-420D-AE7E-99892AD5106F,84F72B64-7E47-444A-889F-280CF0610555 error = {"readyState":4,"responseText":"{\"error\":\"bad_request\",\"reason\":\"invalid_json\"}\n","status":400,"statusText":"Bad Request"} The url called is: http://127.0.0.1/5984/artendb/_all_docs?include_docs=true&keys=[84C19013-D320-420D-AE7E-99892AD5106F,84F72B64-7E47-444A-889F-280CF0610555] CouchDb is version 1.2.0 on windows. Browser is IE10. oh: $(location).attr('host') returns a '/' instead of a ':' before the port! I corrected for that but still get the exact same error. (still scratching my head...) *********************************************************** Alexander Gabriel Wiesenstrasse 22 8800 Thalwil 079/ 372 51 64 alex@barbalex.ch www.barbalex.ch 2013/2/28 Robert Newson > you can do ?keys=["foo","bar"] in newer couchdb version, obviously up > the practical url limit of around 2k (or 4k now?). > > B. > > On 28 February 2013 16:38, Tim Tisdall wrote: > > In that example the variables are being passed in as POST values. You're > > adding them to the URL which is making them GET variables. Do you have > > code examples that you're trying to use in Javascript? Are you using > > jQuery? > > > > > > On Thu, Feb 28, 2013 at 11:32 AM, Alexander Gabriel >wrote: > > > >> Hi > >> > >> The couchdb docs are full of examples using curl. > >> > >> My problem is, I'm a noob and a windows user. And I am programming using > >> Javascript, not Curl (I suspect most of you are?). > >> Well, I have spent quite a while sitting in front of all these examples > >> scratching my head and wondering how to write them in http. I'd better > just > >> ask an example: > >> > >> What would this here: curl -d '{"keys":["bar","baz"]}' -X POST > >> http://127.0.0.1:5984/foo/_all_docs?include_docs=true > >> > >> be in http? > >> > >> I have tried this: > >> http://127.0.0.1:5984/foo/_all_docs?include_docs=true&id=["bar","baz"] > >> > >> In case this is correct then maybe it did not work for me because my > array > >> contains hundreds, sometimes thousands of id's which is why I am looking > >> for a way to fetch them all in one request. > >> > >> What would the best way be to fetch hundreds of docs of which you know > the > >> id and can't use a view? (other than opening every on single) > >> > >> My use-case: Importing big lists into a couch. The data in the uploaded > >> .csv-files comes with id's and has to be inserted into the corresponding > >> docs. > >> > >> Cheers > >> Alex > >> > --047d7b3441423a2afe04d6cc0f15--