Previous Page Arrow Next Page Arrow

13.3 Synchronous Batch Request

SData uses Atom feeds for batch requests. It makes use of the CRUD mechanisms that have been described previously and that apply to individual Atom entries. An SData batch is nothing more than a feed of unpackaged raw XML data containing entries, with a simple markup (http:httpMethod) to tag each entry with the operation that it requests. Here is an example of an SData batch request:

POST /sdata/myApp/myContract/-/salesOrders/$batch HTTP/1.1
Content-Type: application/atom+xml; type=feed
<feed xmlns:sdata="" 
  <title>Sales Orders</title>

**    <http:httpMethod>POST</http:httpMethod>**
      <salesOrder xmlns=""
        sdata:uuid="BE7D7445-7FA4-4c67-AC22-5F6446314771" >
        <contact sdata:key="216" />
            <product sdata:key="72"/>
            <product sdata:key="43" />

    <title>Sales Order 43661</title>
    <content>Sales order 43661: amount 39422,1198</content>
**    <http:httpMethod>PUT</http:httpMethod>**
**    <http:ifMatch>3nqPeQqoGoxQB5xf3NIijw==</http:ifMatch>**
      <salesOrder xmlns="">

  <!-- ... more entries ... -->

In this batch, the first entry creates a new sales order resource, while the second entry updates the shipping date of an existing sales order resource.

The action that needs to be carried out on each entry is indicated by the http:httpMethod element.

If the action needs additional information transmitted via an HTTP header in the non batch case, then the information is placed in an http:xxx element where xxx is the HTTP header name in camel case. For now only http:ifMatch is used in batch requests but more “header elements” may be introduced in the future.


If we ignore these elements, the entry is identical to the entry that would be submitted individually with an HTTP PUT request. Find out more.

The four HTTP methods are supported in the http:httpMethod element: POST, PUT, DELETE and GET.

The GET method is rarely used because the usual way to read several resources in one request is to do a query. But this feature can be used if the consumer has a precise list of resource ids that it needs to read. In some cases it may be easier to build a batch of entries to read than to build a query that selects these entries. Also, the batch gives you precise control over the order in which the entries are returned.

If http:httpMethod is GET or DELETE, the Atom entry SHOULD NOT carry any XML payload for the resource. It only needs to carry the resource id. If it carries an XML payload, it is ignored by the provider.

An individual entry in a batch MUST always correspond to a single resource. The <id> element of a batch entry MUST be a single resource URL; it cannot be a collection URL.

The batch request itself MUST be submitted with a POST.

SData providers that support the batching protocol MUST conform to the rules above.

Previous Page Arrow Next Page Arrow