美文网首页
【Rest】PUT Vs Post in Rest

【Rest】PUT Vs Post in Rest

作者: jackLee | 来源:发表于2016-01-28 10:43 被阅读0次

    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下添加新的对象

    网友的评论:

    • PUT is not for update, it is for replace, note that to create you are replacing nothing with something. POST is absolutely not for update in any shape of form.

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

    • Both PUT and POST can be used for creating.

    相关文章

      网友评论

          本文标题:【Rest】PUT Vs Post in Rest

          本文链接:https://www.haomeiwen.com/subject/ovqjkttx.html