REST packaging

Using web services, it is considered good practice to make multiple service calls in a single message to reduce the number of remote calls. Is there a way to do this using RESTful services?

+5
source share
5 answers

I do not see how batch processing requests make sense in REST. Since the URL of a REST-based service is an operation to execute and data to execute it, executing batch requests will seriously violate the conceptual model.

An exception would be if you performed the same operation with the same data several times. In this case, you can either pass several values ​​for the request parameter or encode this repetition in the body (however, this will really work only for PUT or POST). Gliffy REST API supports adding multiple users to the same folder through

POST /folders/ROOT/the/folder/name/users?userId=56&userId=87&userId=45

which is essentially:

PUT /folders/ROOT/the/folder/name/users/56
PUT /folders/ROOT/the/folder/name/users/87
PUT /folders/ROOT/the/folder/name/users/45

As another commentator noted, search results from a GET can be performed using query parameters:

GET /some/list/of/resources?startIndex=10&pageSize=50

if the REST service supports it.

+4
source

If you really need to batch, Http 1.1 supports the HTTP Pipelining concept, which allows you to send multiple requests before receiving a response. Check here

+4

. HTTP HTTP- , HTTP, HTTP- , ..

, HTTP API REST - REST API

+3

Of course, there is a way, but this will require server-side support. The magic one size doesn't fit all the methods that I know of.

-1
source

All Articles