【Rest】PUT Vs Post in Rest

2016-01-28  本文已影响0人  jackLee

what is rest

Paste_Image.png Paste_Image.png

StackOverFlow上的关于Rest put 和post请求的讨论

http://stackoverflow.com/questions/630453/put-vs-post-in-rest?rq=1
--来自stackOverFlow上的关于,post和put请求区别的一场讨论

Use POST to create, and PUT to update. That's how Rails is doing it, anyway.
PUT /items/1 #=> update
POST /items #=> create

PUT
PUT /resources/<existingResourceId> HTTP/1.1
PUT /resources/<newResourceId> HTTP/1.1
在原来resourceID下进行Put请求,就是对资源的更新
在新的资源ID下进行PUT请求,则是创建新的资源
POST
Create a new resource under the /resources URI, or collection. Usually the identifier is returned by the server.
--POST /resources HTTP/1.1
--POST在原来的资源ID下添加新的对象

网友的评论:

--POST is used to create.
--PUT is used to create or update.

上一篇 下一篇

猜你喜欢

热点阅读