cancel
Showing results for 
Search instead for 
Did you mean: 

CDSE is not working . cdse.connect.to('NorthWind')

atanu_khan
Explorer
0 Kudos

I tried to replicate the blog https://blogs.sap.com/2020/07/27/cap-consume-external-service-part-3/ by jhodel18, however I am getting following error:


Git Link: https://github.com/atanukhan/odata.git

Destination Configuration :

Code:

srv/Catalog-service.js

const cds = require('@sap/cds');
const cdse = require('cdse');

module.exports = cds.service.impl(async function() {
    const { Products } = this.entities;
    const service = await cdse.connect.to('NorthWind');
    this.on('READ', Products, async () => {
        const result = await service.run({ url: 'Products' });
        return result.value;
    });
});

package.json

{
  "name": "RemoteCDSE",
  "version": "1.0.0",
  "description": "A simple CAP project.",
  "repository": "<Add your repository here>",
  "license": "UNLICENSED",
  "private": true,
  "dependencies": {
    "@sap/cds": "^4",
    "cdse": "^1.1.1",
    "express": "^4"
  },
  "devDependencies": {
    "sqlite3": "^5"
  },
  "scripts": {
    "start": "npx cds run"
  },
  "cds": {
    "requires": {
      "NorthWind": {
        "kind": "odata",
        "model": "srv/external/NorthWind",
        "credentials": {
          "destination": "Northwind"
        }
      }
    }
  }
}

mta.yaml

## Generated mta.yaml based on template version 0.4.0
## appName = RemoteCDSE
## language=nodejs; multiTenant=false
## approuter=
_schema-version: '3.1'
ID: RemoteCDSE
version: 1.0.0
description: "A simple CAP project."
parameters:
  enable-parallel-deployments: true
   
build-parameters:
  before-all:
   - builder: custom
     commands:
      - npm install --production
      - npx -p @sap/cds-dk cds build --production

modules:
 # --------------------- SERVER MODULE ------------------------
 - name: RemoteCDSE-srv
 # ------------------------------------------------------------
   type: nodejs
   path: gen/srv
   properties:
     EXIT: 1  # required by deploy.js task to terminate 
   requires:
     - name: demo-destination
     - name: demo-uaa
   provides:
    - name: srv-api      # required by consumers of CAP services (e.g. approuter)
      properties:
        srv-url: ${default-url}
resources:
 - name: demo-destination
   type: org.cloudfoundry.existing-service
   parameters:
     service-name: demo-destination

 - name: demo-uaa
   type: org.cloudfoundry.managed-service
   parameters:
     path: ./xs-security.json
     service: xsuaa
     service-plan: application  

Accepted Solutions (0)

Answers (2)

Answers (2)

jhodel18
Active Contributor
0 Kudos

Hi Atanu,

This is not an issue with CDSE node module.

In order to test the service locally, you will need to get the VCAP_SERVICES environment variable.

  • You can do this by executing the command at the root of your CAP project:
> cf env <your-service-name> > default-env.json
  • Open default-env.json file and delete excess information except for VCAP_SERVICES -- see sample below:
{
    "VCAP_SERVICES": {
        "destination": [
            {...}
        ],
        "xsuaa": [
            {...}
        ]
    }
}
Ramapavani
Participant
0 Kudos

Hi Jhodel,

I am getting below error while consuming on-premise service and running it form SCP -CF post deployement.

<error xmlns="http://docs.oasis-open.org/odata/ns/metadata"> <code>501</code> <message>The server does not support the functionality required to fulfill the request</message> </error>

could you please help here.

Regards,

Rama

david_kunz2
Advisor
Advisor
0 Kudos

Hi,

`cdse` is not part of our delivery, maybe jhodel18 can help out?

However, it looks like you didn't provide the needed environment varibles:
You need to create a file `default-env.json` and paste the environment variables of your deployed app.

Best regards,
David

jhodel18
Active Contributor
0 Kudos

Sure david.kunz2!

Hi Atanu,

I will look into it and revert back here.

atanu_khan
Explorer
0 Kudos

Hi david.kunz2 ,

Actually I was trying to implement a remote odata POST using 'CDS' connect, however I am getting an error of 403.

I raised a question for the same.

https://answers.sap.com/questions/13219732/cds-post-returning-403-for-remote-odata-call.html#

Thank you,

Atanu.