Bulk Collection Manipulation through a REST (RESTful) API

后端 未结 7 730
我寻月下人不归
我寻月下人不归 2020-12-04 06:45

I\'d like some advice on designing a REST API which will allow clients to add/remove large numbers of objects to a collection efficiently.

Via the API, clients need

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 07:30

    As far as I understand it, REST means REpresentational State Transfer, so you should transfer the state from client to server.

    If that means too much data going back and forth, perhaps you need to change your representation. A collectionChange structure would work, with a series of deletions (by id) and additions (with embedded full xml Representations), POSTed to a handling interface URL. The interface implementation can choose its own method for deletions and additions server-side.

    The purest version would probably be to define the items by URL, and the collection contain a series of URLs. The new collection can be PUT after changes by the client, followed by a series of PUTs of the items being added, and perhaps a series of deletions if you want to actually remove the items from the server rather than just remove them from that list.

提交回复
热议问题