on 10-23-2023 4:03 PM
I have this function in a NodeJS application using @sap/cds version 7.3.0:
static async getEquipmentSet() {
try {
const api = await cds.connect.to('sap-odata-service');
const result = await api.get(`EquipmentSet`);
return result;
} catch (error) {
console.log(error);
}
}<br>
This previous GET function returned data from the remote service 'sap-odata-service' configured in the .cdsrc.json file.
But the following POST method returns an error:
static async postHourmeter(equipmentData, measurementPointId) {
try {
const payload = this.getHourmeterPayload(equipmentData, measurementPointId);
const api = await cds.connect.to('sap-odata-service');
const result = await api.post(`MeasureDocumentSet`, payload);
return result;
} catch (error) {
console.log(`The error is:`);
console.log(error);
}
}<br>
Errors:
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT TypeError: Cannot read properties of undefined (reading 'length')
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT at findQueryTarget (/home/vcap/app/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:766:51)
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT at RemoteService.handle (/home/vcap/app/node_modules/@sap/cds/libx/_runtime/remote/Service.js:321:17)
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT at RemoteService.dispatch (/home/vcap/app/node_modules/@sap/cds/lib/srv/srv-dispatch.js:45:15)
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT at /home/vcap/app/node_modules/@sap/cds/lib/srv/srv-dispatch.js:18:43
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT at /home/vcap/app/node_modules/@sap/cds/lib/srv/srv-tx.js:38:55
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT at AsyncLocalStorage.run (node:async_hooks:338:14)
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT at AsyncLocalStorage.run (/home/vcap/app/node_modules/@sap/cds/lib/req/cds-context.js:7:36)
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT at RemoteService.srv_tx (/home/vcap/app/node_modules/@sap/cds/lib/srv/srv-tx.js:38:25)
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT at RemoteService.dispatch (/home/vcap/app/node_modules/@sap/cds/lib/srv/srv-dispatch.js:18:31)
2023-10-23T15:00:06.11+0000 [APP/PROC/WEB/0] OUT at RemoteService.run (/home/vcap/app/node_modules/@sap/cds/lib/srv/srv-api.js:77:17)<br>
Does anyone know how to fix it?
Hi olena_!
Do you have more information about the solution with respect this issue we are facing in SAP CAP?
Thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
11 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.