2.2.7.6.6 Batch Responses

If a data service receives a Batch request (section 2.2.7.6) with a valid set of HTTP request headers, it MUST respond with a 202 Accepted HTTP response code to indicate that the request has been accepted for processing, but that the processing has not yet been completed. The requests within the Batch request body might be malformed or subsequently fail. This mechanism enables clients of a Batch implementation to stream the results of a Batch request without having to first wait for all requests to be processed.

Alternatively, if a data service receives a Batch request with an invalid set of headers, it MUST return a 4xx response code. For example, a Batch request cannot use post tunneling, as described in Tunneled Requests (section 2.2.7.7), and therefore, the presence of an X-HTTP-Method header in a Batch request results in a response containing a 4xx response code.

All responses to Batch request MUST use the multipart/mixed media type by including the Content-Type header as defined by the contentTypeMime rule in the ABNF grammar shown in Batch Request (section 2.2.7.6).

The server is free to re-order responses within a change set. In order for the client to correlate responses with requests, all responses within a change set MUST include the Content-ID MIME part header with the value of the Content-ID specified for the corresponding request. To support early client implementations that specify Content-ID as part of the individual request rather than as a MIME part header for that request and where use within the individual request does not conflict with some other use by the server, servers SHOULD recognize the Content-ID in either location and write it in the response in the same location in which it is read in the request.

Structurally, a Batch Response body MUST match one-to-one with the corresponding Batch Request (section 2.2.7.6) body, such that the same multipart MIME message structure defined for requests is used for responses. The difference is that each MIME part represents a response instead of request. The exception to this rule is that when a request within a change set fails, the change set response is not represented using the multipart/mixed media type. Instead, a single response, using the "application/http" media type, is returned that applies to all requests in the change set and MUST be formatted according to Error Response (section 2.2.8.1).