on 01-04-2021 7:00 AM
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
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.
> cf env <your-service-name> > default-env.json
{
"VCAP_SERVICES": {
"destination": [
{...}
],
"xsuaa": [
{...}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.