Hey guys, thanks for all the great help and your patience with a noob. I've had a fair deal of issues with quoting in curl on windows, also with installing it. Not being a linux console guy I haven't been keen on it since. Alex
Am Donnerstag, 28. Februar 2013 schrieb Tim Tisdall : > You're not properly encoding the javascript object into a JSON string... > you're also not encoding it for being placed in a URL. > > > On Thu, Feb 28, 2013 at 12:17 PM, Alexander Gabriel > <[email protected]<javascript:;> > >wrote: > > > 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 > > [email protected] > > www.barbalex.ch > > > > > > > > 2013/2/28 Robert Newson <[email protected]> > > > > > 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 <[email protected]> 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 < > [email protected] > > > >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 i -- *********************************************************** Alexander Gabriel Wiesenstrasse 22 8800 Thalwil 079/ 372 51 64 [email protected] www.barbalex.ch
