Update an entire resource collection in a REST way

后端 未结 3 1330
礼貌的吻别
礼貌的吻别 2020-11-28 10:14

I have a REST URI for a list of resources, something like:

http://foo.com/group/users

Each of these users has a sequence number and I want

3条回答
  •  星月不相逢
    2020-11-28 10:32

    Semantically speaking, the HTTP PATCH method is the right way to go. This is also described in the currently chosen answer.

    PATCH /group/users
    
    [
        { "id": "userId1", "sequence": "newSequenceNumber1" },
        { "id": "userId2", "sequence": "newSequenceNumber2" },
        ...
    ]
    

    However, the second method described in the chosen answer is not restful, because you invented new verbs inside a POST request. This is SOAP, not REST.

提交回复
热议问题