RESTful api:post 与 put的区别

无论是post还是put,两者都可以创建和更新资源。

  • 创建:post不需要指定被创建资源的id,而put需要指定
  • 更新:两者都要指定被更新资源的id
POST:

> modify and update a resource
POST /questions/ HTTP/1.1

> create a resource:
POST /questions HTTP/1.1

> Note that the following is an error:
POST /questions/ HTTP/1.1


PUT:

> To overwrite an existing resource:
PUT /questions/ HTTP/1.1

> create a resource:
PUT /questions/ HTTP/1.1

参考

Restful API 以及对 Put/Post 区别理解

你可能感兴趣的:(工作记录)