Batch Requests
The library supports OData batch requests, which allow clients to send multiple queries in a single HTTP request, in both wire formats defined by the specification:
- JSON batch (
Content-Type: application/json) — the format used by SAP UI5 V4 OData models, and the one documented in detail below. multipart/mixed— the older MIME format, still emitted by UI5 V2 models and several desktop clients. Send it withContent-Type: multipart/mixed; boundary=<boundary>; the response comes back asmultipart/mixedwith one part per inner request. A missingboundaryparameter is a400.
The format is detected from the request's Content-Type; the same engine, gating, and partial-failure semantics apply to both.
URL
POST /odata/$batch
Content-Type: application/jsonRequest format
json
{
"requests": [
{
"id": "1",
"method": "GET",
"url": "Products"
},
{
"id": "2",
"method": "GET",
"url": "Products(1)?$select=name,price"
},
{
"id": "3",
"method": "GET",
"url": "Categories?$top=5"
}
]
}Each request object contains:
| Field | Required | Purpose |
|---|---|---|
id | yes | Unique identifier for correlating responses |
method | yes | HTTP method (only GET supported) |
url | yes | Relative URL (relative to the service root) |
Response format
json
{
"responses": [
{
"id": "1",
"status": 200,
"body": {
"@odata.context": "...",
"value": [...]
}
},
{
"id": "2",
"status": 200,
"body": {
"@odata.context": "...",
"id": 1,
"name": "Widget",
"price": 9.99
}
},
{
"id": "3",
"status": 400,
"body": {
"error": {
"code": "unknown_entity_set",
"message": "Unknown entity set: Categories",
"target": null,
"details": [],
"innererror": {}
}
}
}
]
}Error handling
Each inner request is processed independently. If one request fails:
- That request gets an error response with the appropriate HTTP status code
- Other requests in the batch continue processing
- The batch response itself returns HTTP 200
Constraints
- Only
GETrequests are supported (read-only service) - Change sets are not supported (no write operations)
- URLs are resolved relative to the service root