cancel
Showing results for 
Search instead for 
Did you mean: 

CAP odata-v2-adapter: batch request is not supported?

MioYasutake
Active Contributor
0 Kudos

Hi community,

I have developed an OData service with CAP using odata-v2-adapter. When I try to execute $batch requests to the v2 endpoint, the service returns the following error:

 

{
    "error": {
        "code": "400",
        "message": {
            "lang": "en",
            "value": "OData-Version '2.0' is not a supported version."
        },
        "severity": "error",
        "target": "/#TRANSIENT#",
        "ContentID": "cov2ap_1",
        "innererror": {
            "errordetails": [
                {
                    "code": "400",
                    "message": {
                        "lang": "en",
                        "value": "OData-Version '2.0' is not a supported version."
                    },
                    "severity": "error",
                    "target": "/#TRANSIENT#",
                    "ContentID": "cov2ap_1"
                }
            ]
        }
    }
}

 

In the request body, odata-version: 2.0 is specified.

request url: /odata/v2/sales/$batch

 

--batch
Content-TYpe: multipart/mixed; boundary=changeset

--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary

POST SalesOrders HTTP/1.1
Content-Type: application/json
odata-version: 2.0

{
    "orderDate": "2024-04-23",
    "customer": "Postman",
    "items": [
        {
            "product": "PC",
            "quantity": 1,
            "price": 1000
        }
    ]
}

--changeset--

--batch--

 

The error is raised at the following line of code.

MioYasutake_0-1714079695766.png

If I remove the "odata-version: 2.0" or change the version to 4.0 (inconsistent with the request url though), the request succeeds. This makes calling the v2 endpoint using SAP Cloud SDK (Java) OData v2 client difficult, as the client (seemingly) sets "odata-version: 2.0". 

Is there any solution for this issue?

View Entire Topic
Dinu
Contributor

 "The "odata-version" header was introduced in OData protocol version 4.0. This header allows clients to specify the version of the OData protocol they understand and want to use in their requests. It helps ensure compatibility between clients and servers when communicating via the OData protocol." - chat GPT

It appears Cloud SDK is using a header introduced in oData version 4.0 while communicating using oData version 2.0 protocol. I guess this needs fix in Cloud SDK.

MioYasutake
Active Contributor
0 Kudos
@Dinu Thanks for your comment. It makes sense to handle this on the Cloud SDK side, if the "odata-version" header was introduced from OData V4.