Hands-On RESTful API Design Patterns and Best Practices
上QQ阅读APP看书,第一时间看更新

Request methods

The client specifies the intended interaction with well-defined semantic HTTP methods, such as GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS. The following are the rules that an API designer should take into account when planning their design:

  • Don't tunnel to other requests with the GET and POST methods
  • Use the GET method to retrieve a representation of a resource
  • Use the HEAD method to retrieve response headers
  • Use the PUT method to update and insert a stored resource
  • Use the PUT method to update mutable resources
  • Use the POST method to create a new resource in a collection
  • Use the POST method for controller's execution
  • Use the DELETE method to remove a resource from its parent
  • Use the OPTIONS method to retrieve metadata