Batch Requests
The library supports OData JSON batch requests, which allow clients to send multiple queries in a single HTTP request. This is the format used by SAP UI5 V4 OData models.
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": 404,
"body": {
"error": {
"code": "not_found",
"message": "Entity set 'Categories' not found."
}
}
}
]
}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