Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

POSTing entities to WebAPI in batch?

Do I need to send individual entity updates to WebAPI, or can I POST an array of them and send them all at once? It seems like a dumb question, but I can't find anything that says one way or another.

like image 671
Majkeli Avatar asked Oct 05 '22 06:10

Majkeli


2 Answers

Brad has a blog post that talks about implementing batching support in Web API.

Also, Web API samples project on codeplex has a sample for doing batching in web API hosted on asp.net.

like image 147
RaghuRam Nadiminti Avatar answered Oct 10 '22 03:10

RaghuRam Nadiminti


It seems like WEB API 2 has support for this

From the site (Web API Request Batching):

Request batching is a useful way of minimizing the number of messages that are passed between the client and the server. This reduces network traffic and provides a smoother, less chatty user interface. This feature will enable Web API users to batch multiple HTTP requests and send them as a single HTTP request.

There are a number of samples for different scenarios on this page.

https://aspnetwebstack.codeplex.com/wikipage?title=Web+API+Request+Batching

like image 39
Nils Avatar answered Oct 10 '22 03:10

Nils