Attempting to delete attachment gives 405 error

84 views
Skip to first unread message

Jason Van

unread,
Aug 18, 2014, 7:08:26 PM8/18/14
to mobile-c...@googlegroups.com
Hey,

I've been trying to delete attachments by using the couchbase lite api but no luck and not sure what I am doing wrong.

I've been using postman to do this (I create attachments using postman and that works fine).

Heres what I do...

DELETE https://{domain}/{bucket}/{doc_id}/{attachment_name}?rev=1-SomeRevisionIdHere
Headers:
Content-Type: image/jpeg

I've also tried it adding the header If-Match: 1-SomeRevisionIdHere instead of the param rev in the url.

On the sync gateway side I see it getting hit..

22:58:16.647588 HTTP:  #035: DELETE /{bucket}/{doc_id}/{attachment_name}?rev=1-SomeRevisionIdHere

But on postman I get a 405 error and the body is..

{
error: "Method Not Allowed"
reason: ""
}

Also the attachment is not deleted.

Does any one have any idea what I am doing wrong?

Thanks!

Jason

Jens Alfke

unread,
Aug 18, 2014, 10:40:23 PM8/18/14
to mobile-c...@googlegroups.com
I don't think we ever implemented the DELETE method for attachments.

Instead just GET the document, remove the attachment metadata from the _attachments property, and PUT it back.

—Jens

Jason Van

unread,
Aug 18, 2014, 10:59:01 PM8/18/14
to mobile-c...@googlegroups.com
Hey Jens,

I was using DELETE method because it was indicated in the rest api. 

The way you just mentioned is way simpler, I just tried it out and worked like a charm, doesn't seem to have problems.

Thanks!

Jason

Jens Alfke

unread,
Aug 19, 2014, 12:41:36 AM8/19/14
to mobile-c...@googlegroups.com

On Aug 18, 2014, at 7:59 PM, Jason Van <jason...@gmail.com> wrote:

I was using DELETE method because it was indicated in the rest api. 

A lot of the REST API docs are based on the CouchDB documentation, and unfortunately weren't checked to see whether Couchbase Lite actually implements each call. Sorry for the confusion.

—Jens
Reply all
Reply to author
Forward
0 new messages