What is the HTTP status return code for a successful DELETE statement in REST?

前端 未结 4 1718
清歌不尽
清歌不尽 2020-12-13 23:39

I am studying how to Spring handle REST web services (but I don\'t know if it is a Spring related answer or more generically it is related only to REST concept).

So

4条回答
  •  囚心锁ツ
    2020-12-14 00:29

    There are no strict rules on which HTTP status code is the correct one for each method. It depends on what exactly happened, what information you need to send to the client, etc. I can think of a few examples:

    • A successful DELETE, with no further information. 204 No Content

    • A successful DELETE, but you have a warning about related orphan resources that should be deleted too. 200 OK.

    • You accepted the DELETE request, but it might take a long time and you're going to do it asynchronously. The client should check it later. 202 Accepted.

    • You accepted the DELETE request, but the resource can't be removed and the URI is instead reset to a default. 205 Reset Content.

提交回复
热议问题