on 08-14-2023 4:49 PM
A stupid question...
I want to consume a remote service (oData) in SAP CAP Java and the URL/result must look like this: xyz.com/myEntity(key1='12345',key2=datetime'2022-02-01')/Results
My select looks like:
<code>SELECT.from(MyService_.CDS_NAME).columns(c -> c.Results().expand(...)).where(w -> w.key1().eq('12345').and().key2(...);
Our problem now is that this Where condition is of course implemented as $filter. But we have to address the entity via keys to get the results. And that without expand. The only examples I found always use byID and that only works with a key. Also other filter/match methods have led to the same undesired result.
The resulting URL looks like this:
<code>//xyz.com/myEntity?$filter=key eq '123' etc.
Is this possible in the Java SDK to have the URL look like described in the beginning?
Or do I have to build a HTTP client myself?
Unfortunately, I can't pull the root entity first. I have to go this way to address the keys and /Result directly. Please don't ask why.
If you want to build a URL path with CQN you need to specify the conditions and path segments in the "ref" of the Select. Please try this:
Select.from(MyEntity_.class, e -> e.filter(e.key1().eq("value1").and(e.key2().eq("value2")).Results()));
BTW: byId() is just a helper method that produces the same where condition as if you would explicitly write ".where(w -> w.myKey().eq('myId')"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
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.