Domanda

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?

È stato utile?

Soluzione 2

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

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top