Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couchbase REST API for inserting/updating a document [closed]

I was looking for the couchbase REST API's for insert/update a document in given bucket, but I couldn't find any. Does anybody knows if such API exist?

Only API i could find is for updating design document:

http://docs.couchbase.com/couchbase-manual-2.5/cb-rest-api/#design-documents-rest-api

like image 426
zer0Id0l Avatar asked Jan 24 '15 05:01

zer0Id0l


4 Answers

It is not documented (thus, probably not supported), but you can do this using the same base URL as the couchbase bucket API (see table 4). The complete path is:

...hostname:8091/pools/default/buckets/{bucketname}/docs/{docid}

To confirm this, just go to your couchbase web console, and use your builtin browser developer tools to check all network queries, and hit save button. You can verify this is the actual REST endpoint that the couchbase web console hits when you open or save a document.

It uses basic HTTP auth. But, instead of bucket password it needs Admin credentials.

Important: You should not rely on this for high performance operations. Performance on number of gets and sets operations using this undocumented REST endpoint is way too slow compared to couchbase official SDK which is optimized protocol that does not carry the HTTP overhead.

like image 50
L. Holanda Avatar answered Nov 06 '22 22:11

L. Holanda


There is no REST API for CRUD operations in Couchbase. If you must use REST, you'll pretty much have to use an external service as a proxy. You can probably use the Couchbase mobile sync gateway as a sort of CRUD service, or roll your own. You can find an example here: https://github.com/couchbaselabs/couchbase-rest-api-rails

like image 43
David Ostrovsky Avatar answered Nov 06 '22 23:11

David Ostrovsky


Created a simple sample that shows CRUD on an existing bucket in Couchbase at:

http://blog.arungupta.me/crud-java-application-with-couchbase-java-ee-and-wildfly/

This is then exposed as a REST API.

like image 2
Arun Gupta Avatar answered Nov 06 '22 23:11

Arun Gupta


REST API's for insert/update a document in given bucket

http://localhost:8092/bucket name/doucmnetId

application/json

{ insert your json data }

create a POST request to your couchbase you can create the document.

create a PUT request you can update your document in couchbase.

like image 1
Prabitha Avatar answered Nov 06 '22 22:11

Prabitha