2024 Feb 28 7:36 PM
Hello everyone,
I am trying to call an unbound action in RAP using CAP.
Based on the documentation I'm trying the send method: https://cap.cloud.sap/docs/node.js/core-services#srv-send-request
const remote = await cds.connect.to("api")
..
let a = await remote.send('entity/namespace.action',{parameters})
console.log(a)
...
No matter what I tell him, right or wrong, he always tells me undefined.
When I call the service via rest client, I receive a correct response.
POST dest.dest/path.../entity/namespace.action
Content-Type: application/json
{parameters}
If I try to call an entity, there is no error/the correct answer.
Has anyone managed a call or an idea what I am doing wrong?
Thank you very much.
Best regards.
By the way, has anyone looked at the curiosity of an unbound action under RAP? I thought the service was built incorrectly.
2024 Mar 04 12:02 PM
I have found a possible solution, but I can imagine that this is what the author had in mind.
await remote.send('POST', 'service.entity/namespace.action', {parameters)
I am very open to further approaches/ideas.
2024 Jun 13 3:19 PM
@akuller I've tried calling RAP unbound action/function in and I also think the implementation is off. The IsBound flag seems to be true, regardless of what I did in the RAP v4 service (declaring it static). I had to make it Odata v2 for it to work
4 weeks ago
In RAP you can declare actions only inside a behavior of an entity. That's why there are only bound actions. The difference here is that we have static actions as well. They are kind of unbound (i.e. they don't require a context) but at the same time they are bound (i.e. they are defined inside an entity). This results in a little confusing URL syntax:
<SERVICE>/<ENTITY_SET>/<NAMESPACE>.<ACTION>
e.g. /sap/opu/odata4/sap/api_purchaseorder_2/srvd_a2x/sap/purchaseorder/0001/PurchaseOrder/com.sap.gateway.srvd_a2x.api_purchaseorder_2.v0001.MarkAsDeleted