I tried to test couchDB's _revs_diff api to get document revisions. Here is the command I used
curl -X POST http://******:******@localhost:5984/grocery-sync/_revs_diff -H "Content-type:application/json"
the result is
{"error":"unknown_error","reason":"badarg"}
Does anyone know the reason for that?
According to the CouchDB wiki page, _revs_diff
will return a value if the revisions for a given document are invalid. No examples using curl
are given.
Looking at this mailing list posting the problem appears to be that you need to include document and revision information, like this:
$ curl -X POST -H "Content-type:application/json" \
http://*:*@localhost:5984/grocery-sync/_revs_diff \
-d '{"0d63eac0ca9a37daa062b23853a4cf4d":["1-e9e4e9c76323a267ff4f780f9f979b9f", "12-3286453e55eb2c401bc194670075f942"]}'
Where the dictionary key (0d63...cf4d
) is the document id and the array are revision ids. In this example both revisions (1-...
and 12-...
) are present in the database so the response is
{}
If I provide a missing revision id (one I invented):
$ curl -X POST -H "Content-type:application/json" \
http://*:*@localhost:5984/grocery-sync/_revs_diff \
-d '{"0d63eac0ca9a37daa062b23853a4cf4d":["1-abcdef"]}'
The response is
{"0d63eac0ca9a37daa062b23853a4cf4d":{"missing":["1-abcdef"]}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With