REST - HTTP DELETE - semantics - delete only descendants

In our project, a list of all books can be obtained through REST:

GET http://server/api/books/

A specific book can be obtained as follows:

GET http://server/api/books/:id/

Removing a specific book is very simple:

DELETE http://server/api/books/:id/

Now, to my question: what should be the result of the following call:

DELETE http://server/api/books/

Obviously all books are deleted. But should resource books be deleted? That is, after the request:

  • should GET / books / return 200 OK with an empty list? or
  • should GET / books / return 404 not be found?

According to the specifications, which say that a specific URI will be deleted later, I would choose the second option. However, in my opinion, this makes things complicated and illogical. It makes sense to have an empty list of books, not books.

What do you think?

+5
3

, , , .: -)

200 OK . , /books/all

do

DELETE /Books/all
+2

? . . .

, , .

0

, DELETE /books . api , "" api-client. , - , (, ) DELETE /books.

, DELETE /books/{id}, .

, : , , DELETE /books ( ). , -, . /user/{id}/shopping-cart/{id}/books. "" (, ), api .

: /books 200 . "null".

0

All Articles