RESTful way to create multiple items in one request

后端 未结 7 488
情书的邮戳
情书的邮戳 2020-11-28 18:40

I am working on a small client server program to collect orders. I want to do this in a \"REST(ful) way\".

What I want to do is:

Collect all orderlines (prod

7条回答
  •  鱼传尺愫
    2020-11-28 19:16

    Although bulk operations (e.g. batch create) are essential in many systems, they are not formally addressed by the RESTful architecture style.

    I found that POSTing a collection as you suggested basically works, but problems arise when you need to report failures in response to such a request. Such problems are worse when multiple failures occur for different causes or when the server doesn't support transactions. My suggestion to you is that if there is no performance problem, for example when the service provider is on the LAN (not WAN) or the data is relatively small, it's worth it to send 100 POST requests to the server. Keep it simple, start with separate requests and if you have a performance problem try to optimize.

提交回复
热议问题