on 07-07-2022 9:31 AM
Hi Community,
we are currently using CAP to connect multiple ODATA Backends (which we do not control) to a unified Frontend. We are using Projected Entities and intercept Frontend requests, filter out the specific ID for that backend System, and then redirect the request to the correct Backend Service.
So far everything has worked fine, except for the search query:
When sending a search request query from the frontend, we get a request like this:
GET http://localhost:4004/v2/ABC/ EntityABC?$skip=0&$top=20&$select=abetc&search=name
However CDS interprets this request as
[cds] - GET /ABC/EntityABC?%24skip=0&%24top=20&%24select=abetc&%24search="name"
It puts quotes around the search term, which when sent to the backend ODATA gives us back an empty set, instead of the data that was actually requested.
Testing this behavior on the backend ODATA directly confirms this, search queries only work when not encapsulated by quotes.
Looking through the request object in our service handler, the query seems to be interpreted correctly, but then at some point CDS encapsulates it.
The request query object that is passed to the server:
{ SELECT: {
from: {
ref: [
'namespace.EntityABC'
]
},
columns: [
{ref:['abetc']}, ]
search: [ {val:'name'} ],
limit: { rows: {val:20}, offset: {val:0} },
orderBy: [
{ref:[ 'abetc' ], sort: 'asc' } ]
}}
CDS definition:
@sap.searchable
@cds.search
service SomeService @(requires : 'authenticated-user') {
entity EntityABC as projection on namespace.ExternalBackend {
key abetc,
key 'somekey' as SystemID : String,
*,
toNavProperty as nav : redirected to navProperty
} excluding {
toNavProperty
};
Is there a way around this behavior? Apart from search, every other operation works out of the box.
Dependencies:
"dependencies": {
"@sap/audit-logging": "^5.5.3",
"@sap/cds": "^5",
"@sap/cds-odata-v2-adapter-proxy": "^1.8.21",
Thank you and kind regards
Max
Hi Max,
As I already mentioned in the issue you raised, starting the next cds version there will be no quoting of search term for OData v2 backend.
Best regards,
Olena
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
11 | |
10 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.