on 04-06-2021 4:40 PM
Hello experts,
does CAP offer support for actions with arbitrary, unstructured and untyped payloads? I need to provide an HTTP endpoint to POST json data to. The json's attributes aren't set in stone and may differ between calls. Is there a way to achieve this using an (unbound) action?
What I'd like to do is to define something along the lines of
// service.cds
service MyService @(path: '/v1') {
action foo(untyped) returns Integer;
}
// service.js
srv.on('foo', async (req) => {
const msg = JSON.stringify(req.data)
console.log(msg)
return 0
})
and then to be able to POST arbitrary payloads like so
###
POST http://localhost:4004/v1/foo
Content-Type: application/json
{ "baz": "bar" }
###
POST http://localhost:4004/v1/foo
Content-Type: application/json
{ "Number": 125, "An array": [ 1, 2, "Paris", "New York" ] }
Is this possible?
Kind regards
Stan
User | Count |
---|---|
72 | |
9 | |
8 | |
6 | |
6 | |
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.