3. Sending Batch Request
Batch request allows grouping multiple operation in a single http request
Batch request is represented as a multipart MIME request with specific
headers and body part
4. Batch Request headers
Batch request is submitted as a single POST request
Batch request should point to the URI : <Service Root URI>/$batch
Batch request should have a Content-Type header specifying a content type of
“multipart/mixed” and a boundary specification.
Eg: Content-Type: multipart/mixed; boundary=batch_36522ad7-fc75-4b56-
8c71-56071383e77b
The number here represent a guid
5. Batch Request body
The body of the batch request should be made up of ordered sequence of
operations and/or changeset
In the batch request body every operation and changeset is represented with
a specific mime-type
A MIME part representing a query operation MUST include a Content-Type
header with value “application/http” and a Content-Transfer-
Encoding“ header with value ”binary”.
6. Sample Request body
POST /service/$batch HTTP/1.1
Host: host
Content-Type: multipart/mixed; boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77b
--batch_36522ad7-fc75-4b56-8c71-56071383e77b
Content-Type: application/http
Content-Transfer-Encoding:binary
GET /service/Customers('ALFKI')
Host: host
--batch_36522ad7-fc75-4b56-8c71-56071383e77b
Content-Type: multipart/mixed; boundary=changeset_77162fcd-b8da-41ac-a9f8-9357efbbd621
Content-Length: ###
-changeset_77162fcd-b8da-41ac-a9f8-9357efbbd621
Content-Type: application/http
Content-Transfer-Encoding: binary
POST /service/Customers HTTP/1.1
Host: host
Content-Type: application/atom+xml;type=entry
Content-Length: ###
<AtomPub representation of a new Customer>
7. Sample Request body Cont.
--changeset_77162fcd-b8da-41ac-a9f8-9357efbbd621
Content-Type: application/http
Content-Transfer-Encoding:binary
PUT /service/Customers('ALFKI') HTTP/1.1
Host: host
Content-Type: application/json
If-Match: xxxxx
Content-Length: ###
<JSON representation of Customer ALFKI>
--changeset_77162fcd-b8da-41ac-a9f8-9357efbbd621--
--batch_36522ad7-fc75-4b56-8c71-56071383e77b
Content-Type: application/http
Content-Transfer-Encoding:binary
GET service/Products HTTP/1.1
Host: host
--batch_36522ad7-fc75-4b56-8c71-56071383e77b--
8. Responding to a Batch Request
A batch response body MUST match one-to-one with the corresponding batch
request body, such that the same multipart MIME message structure defined for
requests is used for responses
The order of ChangeSets and query operations in a Batch request is significant as a
service MUST process the components of the Batch in the order recieved.
All operations in a ChangeSet represent a single change unit so a service MUST
successfully process and apply all the requests in the ChangeSet or else apply none
of them.
If the service receives a Batch request with an invalid set of headers it MUST
return a 4xx response code and perform no further processing of the request.
If the set of request headers of a Batch request are valid (the Content-Type is set
to multipart/mixed, etc) the service MUST return a 2xx Success HTTP response
code