1

A similar question was asked here Getting full list of revisions on document level using CouchDB-Python?, but what I want to do is also to retrieve the bodies of each revision of the same document in one request. I want to effectively build a revision list also showing the past document bodies.

According to the HTTP API: http://wiki.apache.org/couchdb/HTTP_Document_API,

"You can fetch the bodies of multiple revisions at once using the parameter open_revs=["rev1","rev2",...], or you can fetch all leaf revisions using open_revs=all (see Replication_and_conflicts). The JSON returns an array of objects with an "ok" key pointing to the document, or a "missing" key pointing to the rev string"

However, when I run my query with the AJAX option open_revs: ["3-9e93308666d43721e80580acaedd149b","2-6a3187f50d51756820f1908eab7fcf3f","1-e9a0482bf9a120bd03fb5ff03cdd2d3d"] , I get an invalid_json request returned from the Erlang server.

I have checked my revision numbers which I retrieved from an array revs_info parameter, and still no success.

I was thinking that another possible method is to iterate over the rev_info array and requery the server for each revision body, but this seems too inefficient.

What is the correct method to execute this?

Community
  • 1
  • 1
AnthonyS
  • 2,429
  • 2
  • 24
  • 17

2 Answers2

0

Have you tried including the argument include_docs=true? Haven't seen the request you made so I can't tell if it's relevant but if it's a request for a view, here's where it's documented.

Chris
  • 3,438
  • 5
  • 25
  • 27
  • The request I am trying to execute is: GET /database/b30f72bf8a745d19094d2e79b104be16?open_revs=3-9e93308666d43721e80580acaedd149b%2C2-6a3187f50d51756820f1908eab7fcf3f%2C1-e9a0482bf9a120bd03fb5ff03cdd2d3d I passed in an array 3 revision ids of the document I want to retrieve, which should return 3 separate revision bodies of the same doc. Reference here for open_rev http://wiki.apache.org/couchdb/HTTP_Document_API I am using openDoc function call from jquery.couch.js and passing open_revs: ["3-9e93349b","2-6a38eab7fcf3f","1-5ff03cdd2d3d"] as one of the options. Revision numbers are arbitrary. – AnthonyS Aug 29 '12 at 18:10
0

The value of the ?open_revs parameter is a JSON-encoded array of strings. In the example you gave in the comment to the other answer, you're not including either the brackets or the quotes, just the comma-separated IDs. That's why you're getting a JSON error.

(Yes, both the brackets and the quotes have to be URL-escaped too!)

Jens Alfke
  • 1,946
  • 12
  • 15