RESTful Alternatives to DELETE Request Body

前端 未结 4 1823
清歌不尽
清歌不尽 2020-11-29 16:31

While the HTTP 1.1 spec seems to allow message bodies on DELETE requests, it seems to indicate that servers should ignore it since there are no defined semantics fo

4条回答
  •  天命终不由人
    2020-11-29 17:02

    I suggest you include the required metadata as part of the URI hierarchy itself. An example (Naive):

    If you need to delete entries based on a date range, instead of passing the start date and end date in body or as query parameters, structure the URI such a way that you pass the required information as part of the URI.

    e.g.

    DELETE /entries/range/01012012/31122012 -- Delete all entries between 01 January 2012 to 31st December 2012

    Hope this helps.

提交回复
热议问题