SAP Knowledge Base Article - Public

3840048 - OData $batch request to API Business Partner fails with "$count" segment error when entity set is included in URI (SAP S/4HANA Cloud Public Edition)

Symptom

  • Posting a business partner edit request via API Business Partner (A2X) using an OData V2 $batch call returns HTTP 400.
  • Error message: "The request URI is not valid. The segment '$count' refers to an entity set and not to a single entity".

Environment

SAP S/4HANA Cloud Public Edition

Reproducing the Issue

  1. Prepare an OData V2 $batch request to update a business partner address (for example, a PATCH to A_BusinessPartnerAddress inside a changeset).
  2. Send POST to the endpoint path that incorrectly includes an entity set before $batch, for example: /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner/$batch.
  3. Observe the response: HTTP 400 with the error "The request URI is not valid. The segment '$count' refers to an entity set and not to a single entity".

Cause

Using the $batch endpoint with an entity set segment (for example, .../A_BusinessPartner/$batch) is invalid. The OData $batch endpoint must be addressed at the service root only, which leads to a URI parsing error referencing the $count segment.

Resolution

  1. Call the $batch endpoint at the service root only: /sap/opu/odata/sap/API_BUSINESS_PARTNER/$batch (do not include any entity set in the URL path).
  2. Keep the individual request lines inside the batch body as relative requests to the required entity sets (for example, PATCH A_BusinessPartnerAddress(...)).
  3. Optionally verify the endpoint with a simple GET to /sap/opu/odata/sap/API_BUSINESS_PARTNER/$batch to confirm accessibility before sending the POST with changes.
  4. Re-send the batch request and confirm the update completes without the "$count" segment error.

See Also

SAP Help Portal - Batch Request

Keywords

OData, $batch, API_BUSINESS_PARTNER, A_BusinessPartner, URI not valid, $count segment, HTTP 400, entity set, single entity, OData V2, business partner, batch update, PATCH, service root, endpoint configuration , KBA , LO-MD-BP-ODT , OData Service for Business Partner , Problem

Product

SAP S/4HANA Cloud Public Edition all versions