DELETE /{db}/{doc}/{attachment}
This request deletes an attachment to the specified document. To delete an attachment, you must supply the rev query parameter or If-Match header with the current revision identifier.
Request
Request headers
-
Accept—optional—Valid values are:- application/json
- text/plain
-
If-Match– Required if therevquery parameter is not supplied —Revision identifier of the requested document.
Query parameters
| Name | Type | Description | Default |
|---|---|---|---|
batch
| string | Stores the document in batch mode. To use, set the value to ok. | none |
rev
| string | Revision identifier | none |
Message body
None
Response
Status codes
- 200 OK – Attachment successfully removed
- 202 Accepted – Request was accepted, but changes are not yet stored on disk
- 400 Bad Request – Invalid request body or parameters
- 401 Unauthorized – Write privileges required
- 404 Not Found – Specified database, document or attachment was not found
- 409 Conflict – Document’s revision wasn’t specified or it’s not the latest
Response headers
-
Content-Type—The value can be:- application/json
- text/plain; charset=utf-8
-
ETag—Revision identifier enclosed in double quotes
Message body
The response is a JSON document that contains the following objects:
| Name | Type | Description |
|---|---|---|
| id | String | Document identifier |
| ok | Boolean | Indicates whether the operation was successful |
| rev | String | revision identifier |
Example
The following example deletes the attachment that was added in a previous example.
Request
DELETE /cookbook/LemonChicken/lcnote.txt?rev=2-6847bbc089e24db84bd0371b9c169566
Host: localhost:59840
Response
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 91
Content-Type: application/json
Date: Sat, 14 Dec 2013 00:32:26 GMT
Etag: "3-6210945863a15ee7eff1e540133d19da"
Server: CouchbaseLite 1.486
{
"id" : "LemonChicken",
"rev" : "3-6210945863a15ee7eff1e540133d19da",
"ok" : true
}