What status code should I set for UPDATE
(PUT
) and DELETE
(e.g. product successfully updated)?
相关问题
- Angular RxJS mergeMap types
- Google Apps Script: testing doPost() with cURL
- How to instantiate Http service in main.ts manuall
- C#使用http访问网络,有办法用指定网卡访问网络嘛?
- PHP Empty $_POST
相关文章
- C#使用http访问网络,有办法用指定网卡访问网络嘛?
- Is a unicode user agent legal inside an HTTP heade
- git: retry if http request failed
- Flutter - http.get fails on macos build target: Co
- C# HttpClient.SendAsync always returns 404 but URL
- Response body is null, status is 200
- Returning plain text or other arbitary file in ASP
- jquery how to get the status message returned by a
Since the question delves into if DELETE "should" return 200 vs 204 it is worth considering that some people recommend returning an entity with links so the preference is for 200.
http://blog.ploeh.dk/2013/04/30/rest-lesson-learned-avoid-204-responses/
Personally I would not say 204 is wrong (neither does the author; he says "annoying") because good caching at the client side has many benefits. Best is to be consistent either way.
For a PUT request: HTTP 200 or HTTP 204 should imply "resource updated successfully".
For a DELETE request: HTTP 200 or HTTP 204 should imply "resource deleted successfully". HTTP 202 can also be returned which would imply that the instruction was accepted by the server and the "resource was marked for deletion".
Source: w3.org: HTTP/1.1 Method Definitions
Source: List of HTTP status codes: 2xx Success