繁体   English   中英

如何为批量保存设计一个Restful API?

[英]How to Design a Restful API for a Bulk Save?

在我的RESTful Web API应用程序中,我目前正在使用以下模板:

Get one product by id: 
GET api/product/12

Save product
POST api/product

Update product
PUT api/product

批量发布的最佳uri模板是什么?

我的初始想法是这样的:

POST api/product/bulk
[WebInvoke(Method = "POST",BodyStyle = WebMessageBodyStyle.Wrapped,
 ResponseFormat = WebMessageFormat.Json,
 RequestFormat = WebMessageFormat.Json)]

void SaveProduct(int productId);

假设您具有正确实施的以下服务。 为此,您的服务uri将是:

YOURDOMAIN / SaveProduct /的productId = productIdNumber

我发现这更直观:

POST api/products

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM