Utilizing HTTP demand headers, you can speak with CouchDB. Through these solicitations we can recover information from the data set, store information in to the data set as records, and we can see just as arrangement the reports put away in a data set.
HTTP Request Formats
Following are the diverse solicitation configurations of HTTP Protocol used to speak with CouchDB.
- GET − This arrangement is utilized to get a particular thing. To get various things, you need to send explicit url designs. In CouchDB utilizing this GET demand, we can get static things, data set records and design, and measurable data as JSON reports (by and large).
- HEAD − The HEAD technique is utilized to get the HTTP header of a GET demand without the body of the reaction.
- POST − Post solicitation is utilized to transfer information. In CouchDB utilizing POST solicitation, you can set qualities, transfer archives, set record esteems, and can likewise begin certain organization orders.
- PUT − Using PUT demand, you can make new articles, data sets, reports, perspectives and configuration archives.
- Erase − Using DELETE demand, you can erase records, perspectives, and configuration archives.
- Duplicate − Using COPY strategy, you can duplicate records and items.
HTTP Request Headers
HTTP headers ought to be provided to get the correct arrangement and encoding. While sending the solicitation to the CouchDB worker, you can send Http demand headers alongside the solicitation. Following are the distinctive Http demand headers.
- Content-type − This Header is utilized to determine the substance sort of the information that we supply to the worker alongside the solicitation. Generally the sort of the substance we send alongside the solicitation will be MIME type or JSON (application/json). Utilizing Content-type on a solicitation is strongly suggested.
- Acknowledge − This header is utilized to indicate the worker, the rundown of information types that customer can see, so the worker will send its reaction utilizing those information types. By and large here, you can send the rundown of MIME information types the customer acknowledges, isolated by colons.
However, utilizing Accept in inquiries of CouchDB isn't needed, it is energetically prescribed to guarantee that the information returned can be handled by the customer.
These are the headers of the reaction sent by the worker. These headers give data about the substance send by the worker as reaction.
- Content-type − This header indicates the MIME kind of the information returned by the worker. For most solicitation, the returned MIME type is text/plain.
- Store control − This header proposes the customer about treating the data sent by the worker. CouchDB generally restores the must-revalidate, which shows that the data ought to be revalidated if conceivable.
- Content-length − This header restores the length of the substance sent by the worker, in bytes.
- Etag − This header is utilized to show the correction for an archive, or a view.
Following is the plain type of the status code sent by the http header and its depiction.
|Sr.No.||Status Code & Description|
200 − OK
This status will be issued when a request completed successfully.
201 − Created
This status will be issued when a document is created.
202 − Accepted
This status will be issued when a request is accepted.
404 − Not Found
This status will be issued when the server is unable to find the requested content.
405 − Resource Not Allowed
This status is issued when the HTTP request type used is invalid.
409 − Conflict
This status is issued whenever there is any update conflict.
415 − Bad Content Type
This status indicated that the requested content type is not supported by the server.
500 − Internal Server Error
This status is issued whenever the data sent in the request is invalid.
HTTP URL Paths
There are sure url ways utilizing which, you can interface with the information base straightforwardly. Following is the even organization of such url ways.
|Sr.No.||URL & Operation|
This url is used to create a new database.
This url is used to get the information about the existing database.
This url is used to create a document/update an existing document.
This url is used to get the document.
This url is used to delete the specified document from the specified database.
This url is used to get the definition of a design document.
This url is used to access the view, view-name from the design document from the specified database.