1

I have a RESTful API. DELETE /Collection/<Object-ID> will delete the specified object. We don't delete the objects internaly. It will only marked as deleted.

Now it is required to enter a delete comment. How is this possible with REST?

Snoopy
  • 33
  • 4
  • 1
    Possible duplicate: http://stackoverflow.com/questions/14323716/restful-alternatives-to-delete-request-body – Jonathan W Nov 14 '13 at 17:51

2 Answers2

3

You have many options (as outlined in this question), but none of them are really considered standard practice. I personally would avoid using custom HTTP headers, but then you might run into trouble with certain HTTP implementations disallowing (or even ignoring) request bodies when sending DELETEs.

Community
  • 1
  • 1
Jonathan W
  • 3,759
  • 19
  • 20
0

You can add a custom http header on the request from the client, and then read it from the server.

Edit:

Example for request with custom header:

DELETE /path/to/resource HTTP/1.1
Host: localhost:8080
Accept: */*
Delete-Comment: not needed anymore

Response:

HTTP/1.1 410 Gone
Date: Thu, 14 Nov 2013 13:56:26 GMT
Content-Length: 0

Note that X-Headers are deprecated: Custom HTTP headers : naming conventions

Community
  • 1
  • 1
Carlos487
  • 1,459
  • 13
  • 17