Skip to Content

OData parameter expand in XSA and XSODATA file

I'm using XS Advanced (SAP HANA SPS12) to develop an application with SAPUI5 and Node.js. I'm exposing my CDS Views as OData with a .xsodata file.

I've created the Associations and the Navigations for the OData entity. Almost everything is working pretty fine. I can load the OData service in my UI5 model and bind the properties.

The problem is I cannot use OData parameter $expand! If I bind the element using the full path it works, if I use $expand, it doesn't work!

With full path: returns status 200 (OK)
https://myhost/services.xsodata/Entities('key')/navToAnotherEntity

With $expand: returns status 500 (Internal Server Error)

https://myhost/services.xsodata/Entities('key')?$expand=navToAnotherEntity

This is the error message when I try to use the parameter $expand

{
  "error": {
    "code": 500,
    "message": {
      "lang": "en-US",
      "value": "Cannot read property 'type' of undefined"
    }
  }
}

Taking a look at the document SAP HANA Help, chapter SAP HANA Developer Guide for XS Advanced Model > Defining OData Services for XS Advanced Applications > OData Parameter Entity Sets, it says:

"This navigation property cannot be used in combination with the OData query options $expand, $filter and $orderby."

But I'm not using any SAP HANA Calculation Views, I'm using only CDS Views. I'm not using parameterized entity. Why does the error happen?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 23, 2016 at 02:30 PM

    On an expand you don't put the navigation name but instead the child entity itself.

    Add comment
    10|10000 characters needed characters exceeded