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
OliverKlemenz
Advisor
Advisor

Hello, 

thanks for asking this question. Of course this is very inconvenient. The next release of CDS OData V2 adapter, will fix this issue, by removing the headers, before sending the OData V4 request. 

Best regards, 

Oliver

MioYasutake
Active Contributor
0 Kudos
@OliverKlemenz Thanks for your quick reply. Glad to hear that the issue will be fixed.
OliverKlemenz
Advisor
Advisor
0 Kudos

New CDS OData V2 Adapter version 1.12.9 is available:

https://github.com/cap-js-community/odata-v2-adapter/releases/tag/v1.12.9

Please check, that issue should be now resolved.