Skip to content

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 with Content-Type: multipart/mixed; boundary=<boundary>; the response comes back as multipart/mixed with one part per inner request. A missing boundary parameter is a 400.

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/json

Request 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:

FieldRequiredPurpose
idyesUnique identifier for correlating responses
methodyesHTTP method (only GET supported)
urlyesRelative 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

In a multipart/mixed batch every part gets a response in its position since 4.0, because a client pairs responses with requests by position. A part that holds no readable request answers 400 (invalid_batch_part, saying what was wrong), and a change set answers one 405 (changeset_not_supported). UI5's OData V4 model sends a change set by itself when a field bound two-way to an OData property is edited: on this read-only service, such a write belongs in an action. changed in 4.0Both kinds of part used to be dropped, so the response had a part fewer than the request, and UI5 failed every request after the gap.

Constraints ​

  • Only GET requests are supported (read-only service)
  • Change sets are not supported (no write operations); each is answered with a 405
  • URLs are resolved relative to the service root