Вопрос

I ran into a REST API at work (developed by another team) and noticed a couple of the DELETE api required Json object (list of ids to be deleted). Is this one of the standard REST DELETE? The DELETE I am used to does not require input Json. Thanks in advance to your replies.

Это было полезно?

Решение

According to the HTTP Semantics document:

   A payload within a DELETE request message has no defined semantics;
   sending a payload body on a DELETE request might cause some existing
   implementations to reject the request.

Therefore, the existence or usage of a payload in a RESTful DELETE is implementation-specific.

However, RESTful deletes using the DELETE verb usually use the resource id in the URL:

DELETE /resource/{id}

In your description, it sounds like the list of ids to be deleted is passed in the payload. In this case, I think it would be more appropriate to use POST:

POST /resource?action=deletelist
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top