简体   繁体   English

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

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

In my RESTful Web API application, I am using the below templates at the moment: 在我的RESTful Web API应用程序中,我目前正在使用以下模板:

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

Save product
POST api/product

Update product
PUT api/product

What is the best uri template for bulk post? 批量发布的最佳uri模板是什么?

My inital thought is this: 我的初始想法是这样的:

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

void SaveProduct(int productId);

suppose that, you have the following service with proper implementation. 假设您具有正确实施的以下服务。 for this, your service uri will be : 为此,您的服务uri将是:

yourDomain/SaveProduct/productId=productIdNumber YOURDOMAIN / SaveProduct /的productId = productIdNumber

我发现这更直观:

POST api/products

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

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