on 2024 Aug 06 5:39 PM
I'm consuming a remote service that has entity sets and multiple actions. I am able to query a projection on that service and get a list of entities. But once I try to use an action that creates a new entity, the backend code is never called. I followed this tutorial to invoke the action.
await srv.send('create_entity',dataObject)
When that didn't work, I thought maybe the 'send' function wasn't properly being used, so I added the method like in this code snippet.
bupa.send({
method: 'POST',
path: create_entity,
data: dataObject
})
This time I got an error telling me that the csrf token was missing. I followed this tutorial to add csrf handling, but the error remained.
"cds": {
"requires": {
"REMOTE_SERVICE": {
"kind": "odata",
"model": "srv/external/REMOTE_SERVICE",
"csrf": true,
"csrfInBatch": true
}
}
}
Is there a problem with the remote service that I'm consuming? Is there a sample project that consumes a remote service action?
Thanks!
await srv.send("POST",'/Entity/SAP__self.create_entity',dataObject, {});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's difficult to assess based on the snippets you shared, but I see you are 'sending' the command to srv and to bupa. Make sure to define and connect to the remote source first (e.g. const bupa = await cds.connect.to("REMOTE_SERVICE"); ). This tutorial should guide you through it end-to-end: https://developers.sap.com/tutorials/btp-app-ext-service-add-consumption..html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
62 | |
12 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.