Skip to main content

configure-serialization

By default, URLs in the multipart representation of a request are serialized to a path relative to the service, e.g.:

GET /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartnerAddress HTTP/1.1

However, some services might only understand URLs relative to the entity or even absolute URLs.

To configure the serialization of the URLs within a batch request, you can set the subrequest path type using the withSubRequestPathType() method. You can choose from the following options:

  • relativeToService (default), which yields URLs relative to the service
  • relativeToEntity, which yields URLs relative to the entity
  • absolute, which produces absolute URLs
  • noPath, which only returns the entity with no preceding path

See below for examples:

Serialize subrequest path relative to entity:

// GET /A_BusinessPartnerAddress HTTP/1.1
batch(...requests).withSubRequestPathType('relativeToEntity');

Serialize subrequest without a preceding path (like relativetoEntity without a leading slash):

// GET A_BusinessPartnerAddress HTTP/1.1
batch(...requests).withSubRequestPathType('noPath');

Serialize subrequest path as absolute URL:

// GET https://my-s4.system.com/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartnerAddress HTTP/1.1
batch(...requests).withSubRequestPathType('absolute');