Skip to content

Accessing batch responses for OData V4 #386

Description

@puja-saraswat

Hello Team,

We're encountering an issue with the response of oData v4 batch request.
I've referred to the documentation for the Generic multipart batch request .

https://sap.github.io/cloud-sdk/docs/java/features/odata/generic-untyped-odata-client

Issue Description

an error occurs when executing batchResult.getResult(requestRead).

com.sap.cloud.sdk.datamodel.odata.client.exception.ODataResponseException: Unable to extract batch response item at position 1. The response contains only 0 items.

further debugging shows that batch result has HttpResponse but size of batchedresponses is 0.
batchResult.getBatchedResponses(); returns empty list.

Important information:
https://github.tools.sap/ComplaintHandling/ICHAMP/blob/03fda19b7d8760642bd27da64231a509372c5eb4/cmh-common/src/main/java/com/sap/ic/cmh/network/service/HttpService.java#L754

  • Your code
// create an HTTP client
String servicePath = "sap/opu/odata4/sap/api_complaintprocessflowdetail/srvd_a2x/sap/complaintprocessflowdetail/0003/";
HttpClient httpClient = HttpClientAccessor.getHttpClient(destination);
// instantiate custom OData V4 batch request
ODataRequestBatch requestBatch = new  ODataRequestBatch(servicePath, ODataProtocol.V4);
ODataEntityKey key = new ODataEntityKey(ODataProtocol.V4)
				.addKeyProperty("P_SubsequentDoc", "65000781")
				.addKeyProperty("P_SubsequentDocItem", "10");
// instantiate custom OData ResourcePath request
ODataResourcePath functionPath =
		new ODataResourcePath()
			.addSegment("ComplaintProcessFlow", key).addSegment("Set");

ODataRequestReadByKey request = new ODataRequestReadByKey(servicePath,functionPath,"$expand=_SubsequentProcFlowDocItem($orderby=ProcessFlowLevel)", ODataProtocol.V4);
		requestBatch.addReadByKey(request);

ODataRequestResultMultipartGeneric  batchResult = requestBatch.execute(httpClient);
ODataRequestResultGeneric queryResult1 = batchResult.getResult(request);
  • Expected outcome
    batchResult.getResult(request) should return List<List> batchResponseItems >0

  • Actual outcome
    batchResult.getResult(request) should return List<List> batchResponseItems = 0

  • Steps attempted to resolve the issue

  • In case of issues with any of our VDMs:

    • What happens when a request is performed directly via an HTTP client tool such as Postman?
    • In case that succeeds please provide details on the request such as URL, query parameters, header parameters, prerequisite requests (e.g. CSRF token), etc.
  • Potentially missing information (open questions you might have)

Impact / Priority

Affected development phase: Development

Impact:
customerComplaint-srv-2024-04-03 07_30_40.336+0000.txt
Blocked

Timeline: e.g. Go-Live is in 12 weeks.

Error Message

Please paste your stracktrace here within the backticks (replacing this comment)

Project Details

  • SDK Version:
  • Link to GitHub repo:
  • Project type, for example:
    • CAP Project
    • SDK Maven Archetype
    • None of the above:
  • Platform:
    • Cloud Foundry
    • Deploy with Confidence (Cloud Foundry)
    • None of the above:

Checklist

  • Checked out the documentation and Stack Overflow
  • Description provided with all relevant information
  • Exception and stack trace provided
  • Attached debug logs
  • Attached dependency tree
  • Provided Cloud SDK version & link to relevant source code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions