I'm facing some issue by reading nested data from an odata api. I'm using Olingo4 with camel 3.20.5.
I first have to filter a collection by key and then want to return a collection from this value. The key-filter is a string, containing a space. In the browser, everything works fine. The url looks like this:
http://baseOdataUrl/Customer('23 abc')/Orders
where Customer
is a collection and Orders
is a NavigationProperty
with type Collection(NAV.Orders)
.
My camel route looks like this:
from("timer:mytimer?period=1000")
.to("olingo4://read/Customer('23 abc')/Orders?serviceUri=baseOdataUrl&httpAsyncClientBuilder=#myHttpClientBuilder");
which is failing with error: Illegal character in url
which indicates, it's not being parsed properly at the position of the space.
I tried several approaches:
from("timer:mytimer?period=1000")
.to("olingo4://read/Customer('23%20abc')/Orders?serviceUri=baseOdataUrl&httpAsyncClientBuilder=#myHttpClientBuilder");
which is not returning anything.
from("timer:mytimer?period=1000")
.to("olingo4://read/Customer/Orders?serviceUri=baseOdataUrl&httpAsyncClientBuilder=#myHttpClientBuilder");
failing: Orders is not allowed after a collection
from("timer:mytimer?period=1000")
.setHeader("CamelOlingo4.keyPredicate", constant("23 abc"))
.to("olingo4://read/Customer/Orders?serviceUri=baseOdataUrl&httpAsyncClientBuilder=#myHttpClientBuilder");
which is trying to filter the Orders, I think, because it's generating url like /Customer/Orders(23 abc)
from("timer:mytimer?period=1000")
.setHeader("CamelOlingo4.keyPredicate", constant("'23 abc'")) // failing like before
.setHeader("CamelOlingo4.keyPredicate", constant("'23%20abc'")) // failing like before
.to("olingo4://read/Customer/Orders?serviceUri=baseOdataUrl&httpAsyncClientBuilder=#myHttpClientBuilder");
I also tried to urlencode the '
and double them. Still no luck.
This working, but not what I want, because it's just returning the customers:
from("timer:mytimer?period=1000")
.setHeader("CamelOlingo4.$filter", constant("Name eq '23 abc'"))
.to("olingo4://read/Customer?serviceUri=baseOdataUrl&httpAsyncClientBuilder=#myHttpClientBuilder");
This is generating an empty node Orders
inside of Customers:
from("timer:mytimer?period=1000")
.setHeader("CamelOlingo4.$filter", constant("Name eq '23 abc'"))
.setHeader("CamelOlingo4.$expand", constant("Orders"))
.to("olingo4://read/Customer?serviceUri=baseOdataUrl&httpAsyncClientBuilder=#myHttpClientBuilder");
If I'm executing this in the browser, it's producing the same wrong result.
So I just want to execute the working browser query from the beginning in camel and get the same correct results there.
The httpClientBuilder is only being used for the NTLM authentication.
I think, it's an easy query, which is running perfectly fine in browser, so there must be an issue with my syntax in camel.
UPDATE
It's working now, with the following route:
from("timer:mytimer?period=1000")
.setHeader("CamelOlingo4.resourcePath", constant("Customer('23%20abc')/Orders"))
.to("olingo4:read?serviceUri=baseOdataUrl&httpAsyncClientBuilder=#myHttpClientBuilder");
Probably there were some issues during encoding. But now, I'm getting the following error:
ODataException: "Unsupported resource type: navigationProperty"
Is it not possible, to process the data?
Many thanks in advance, and let me know, if I need to provide more information.
I ended up, using the http
component of camel, put all the attributes like $filter
and $orderby
in the url and unmarshal the result as json with the Jackson
library into my POJO.
Thanks anyway for reading