Skip to Content
Oct 14, 2019 at 10:52 AM

Problem accessing single entity using OData v4


Hi all,

I created a simple project using the CAP and Node.js. The sources are available here: My project just consist of a single CDS entity called SurveyResponses, which is exposed via a service. The CDS of the entity looks like this:

namespace de.fhaachen.rqkws19;
entity SurveyResponses {   key ID : UUID;   orderid : Integer;   orderDate : DateTime;   ...}

After adding some dummy data to the database using an SQL script I' able to access all the entities in the DB using this URL: /survey/SurveyResponses

In OData v4 it is possible to address a single entity via its identifier. Here is an example with the Northwind service on the When I try the same using my service, e.g. using this URL /survey/SurveyResponses('E65A56807C68EFCA160009027C5C71B7'), I get the following error message:

Expected uri token 'ODataIdentifier' could not be found in 'SurveyResponses('E65A56807C68EFCA160009027C5C71B7')' at position 17

When I try to access an entity using the following $filter expression: /survey/SurveyResponses?$filter=ID eq E65A56807C68EFCA160009027C5C71B7, I get this error message

Property 'E65A56807C68EFCA160009027C5C71B7' does not exist in type 'SurveyService.SurveyResponses'

However, If I try to access the orderid property using a filter everything works as expected. The request to /survey/SurveyResponses?$filter=orderid eq 263 results in

  "@odata.context": "$metadata#SurveyResponses",
  "@odata.metadataEtag": "W/\"v7XePRvoicjsrRX1rhd6CPTx23lX+KlEgqRqmcp4pts=\"",
  "value": [
      "ID": "E65A56807C68EFCA160009027C5C71B7",
      "orderid": 263,
      "orderDate": "2019-10-09T14:40:18Z",
      "netPromoterScore": 4,
      "review": "",
      "marketingOptIn": false,
      "responseDate": null,
      "status": 1

Any Idea how to solve this? Did I miss something in the definition of the entity or the service?

Thanks in advance.