In REST, should I return the representation in response to a PUT?

前端 未结 4 2007
猫巷女王i
猫巷女王i 2020-12-25 13:31

It is conceivable that another client also modified other aspects of the resource in the interim. So is it best practice to always include the full representation in the re

4条回答
  •  半阙折子戏
    2020-12-25 14:09

    Jldupont's comment pointed me in the right direction. I will use ETags to determine whether the resource has been modified, by doing a conditional PUT using the If-match header, as described here.

    Then, in case of a conflict, I'll let the user decide whether to fetch the latest representation from the server (GET) or overwrite the changes with his own.

    Thus, there is no need to return the full representation in the response to the PUT just to help with conflict detection and resolution.

提交回复
热议问题