Get all docs api endpoint return Bad Request

curl -X GET "http://127.0.0.1:4985/foo/-Cl1xFEbqiZWjstOYw-QfRr?attachments=false&revs=false&show_exp=false" -H "accept: application/json"

I call the api above and return doc -Cl1xFEbqiZWjstOYw-QfRr.

{
  "_id":"-Cl1xFEbqiZWjstOYw-QfRr",
  "_rev":"1-c8b8bfe983f5358bfea6aa8254000482e751475d"
  ......
}

However, I call the api below and it returns Bad Request.

curl -X GET "http://127.0.0.1:4985/foo/_all_docs?access=false&channels=true&include_docs=true&revs=false&update_seq=false&keys=-Cl1xFEbqiZWjstOYw-QfRr" -H "accept: application/json"
{"error":"Bad Request","reason":"Bad keys"}

Keys must be an array.

Example : This request retrieves documents with Ids test1 and -test4.

curl -X GET \
  'http://localhost:4985/test_db/_all_docs?access=false&channels=false&include_docs=false&revs=false&update_seq=false&limit=5&keys=[%22test1%22,%22-test4%22]' \
  -H 'Accept: application/json' 

Any reason you are using the _all_docs API for fetch specific documents? The _all_docs is an expensive operation

Thanks, it works.

Maybe something wrong with the doc https://docs.couchbase.com/sync-gateway/current/refer/rest-api-admin.html#/database/get__db___all_docs

Hi, I agree docs could be clearer on this. I have raised a ticket to resolve it https://issues.couchbase.com/browse/DOC-7821

1 Like

Cool. And following up on my question -

I use it to debug whether the doc will be delivered to the correct channel or not.

In that case, I would suggest using _raw API. The all_docs is an expensive operation.