2024 Oct 22 12:59 AM - edited 2024 Oct 22 1:01 AM
I encountered an error when trying to create a custom action for my services in my CAP project. Here's some of my code:
My CDS service file:
using {mySchema as my} from './mySchema';
service myService @(path: '/api/v1/myService') {
entity mySchema as projection on my.mySchema;
// My custom action
action myAction(id: Integer) returns String;
}
My js service file:
const cds = require('@sap/cds');
class myService extends cds.ApplicationService{
init() {
this.on('myAction', async (req) => {
console.log('Hello from my action');
console.log(`Id: ${req.data.id}`);
return 'Hello from my action';
});
return super.init();
}
}
When I executed the following endpoint with PUT in Postman: http://localhost:8080/api/v1/myService/myAction(id=28), I received this error:
{
"error": {
"code": "500",
"message": "Cannot read properties of undefined (reading '_target')"
}
}
Does anyone know why I'm getting this error or if there's documentation about this? Did I forget to include something?
Request clarification before answering.
| User | Count |
|---|---|
| 18 | |
| 7 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.