Skip to Content

By default oData version is v4 in CAP node project

I'm trying to create Odata service using CAP (nodeJS) and by default oData version is coming as V4 and not V2 even though cds env set for v2:

INLM50938888A:techApp i073642$ cds env
build.target = .
build.tasks = [ { for: 'node-cf', src: 'srv', options: { model: [Array] } } ]
features.localized = true
folders.app = app
folders.db = db
folders.srv = srv
i18n.default_language = en
i18n.folders = [ '_i18n', 'i18n', 'assets/i18n' ]
mtx.api.model = true
mtx.api.provisioning = true
mtx.domain = default
odata.version = v2
requires.db.credentials.database = techAPP.db
requires.db.kind = sqlite
requires.db.model = [ 'db', 'srv' ]
sql_mapping = plain

metadata headers
connection →keep-alive
content-length →66647
content-type →application/xml
date →Tue, 28 May 2019 07:25:17 GMT
etag →W/"VGAHNDOlmFoFD6MHH63mUIi269FvPCSF/ieYoryJb3k="
odata-version →4.0
x-powered-by →Express

Could you please help with how to switch the oData version to V2.

Add comment
10|10000 characters needed characters exceeded

2 Answers

  • Best Answer
    Posted on May 28, 2019 at 12:33 PM

    The Node.js server can only provision Odata v4 services, which is why it forcefully overrides cds.env with 'v4'. We are aware of the inconsistency with cds.env's output and will fix is this in one of the next releases.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 30 at 07:10 AM

    As mentioned above, the Node.js stack does not natively support OData v2. However, there is an 'adapter' package that converts v4 to v2 and vice versa. Please check the odata-2-adapter-proxy module for this.

    Add comment
    10|10000 characters needed characters exceeded