Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

CouchDB REST API for Document CRUD Operations — Examples With Postman

DZone 's Guide to

CouchDB REST API for Document CRUD Operations — Examples With Postman

In this tutorial, we will learn how to perform CRUD operations with the help of HTTP requests firing from Postman.

· Integration Zone ·
Free Resource

In this tutorial, we will learn how to perform CRUD operations with the help of HTTP requests firing from Postman.

Assumptions

  1. The CouchDB Server is running at http://127.0.0.1:5789/
  2. Database name is tutorialkart.
  3. The database contains the following two documents (viewed in table view).

Documents in CouchDB Database

View Document — GET Request

Request type: GET

URL: http://hostname_or_IP:Port/databasename/document_id/

URL for this Example: http://127.0.0.1:5984/tutorialkart/0001/

CouchDB - GET Document

Update Document — PUT Request

Request type: PUT

URL: http://hostname_or_IP:Port/databasename/document_id/

URL for this Example: http://127.0.0.1:5984/tutorialkart/0001/

Request Body:

{
    "_rev": "2-74fe79dd659ef45ae32956d3ad4985ab",
    "category": "NoSQL Databases"
}

_rev has to be sent for the document which you would like to edit, along with the fields that need an update. You will get _rev when you GET the document.

Image title

Delete Document — PUT Request

Request type: DELETE

URL: http://hostname_or_IP:Port/databasename/document_id/?rev=revsion_number

URL for this Example: http://127.0.0.1:5984/tutorialkart/0001/?rev=3-d740acd633d56c9522915fa9fc4579e7

_rev has to be sent for the document which you would like to delete as a parameter in the request.

CouchDB - DELETE Document

Create Document — PUT Request

Request type: PUT

URL: http://hostname_or_IP:Port/databasename/new_document_id/

URL for this Example: http://127.0.0.1:5984/tutorialkart/0003/

Request Body:

{
  "tutorial": "Spark Tutorial",
  "category": "Big Data",
  "topics": 4
}

_rev has to be sent for the document which you would like to edit, along with the fields that needs an update. You will get _rev when you GET the document.

Image title

Conclusion

Concluding this article, we have learned how to make CRUD operations for a document in CouchDB Database, with the help of Postman.

Topics:
couchdb ,nosql ,rest api ,crud api ,integration ,postman

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}