I’m using OData to expose some entities in the domain model, and I’m struggling with the string functions mentioned in §4.2 of the OData query options.
Simple filtering with ‘eq’ works, as does combining predicates with ‘and’ and ‘or’. For example, this URL would give me one SKU record
However, when I try to use ‘startswith’, it fails. I’ve noticed the documentation omits the $filter parameter in the examples, but from general OData documentation I know that this should be the query:
This gives me an error:
<message xml:lang="en-US">Unhandled expression type: CallExp</message>
I’ve tried to add spaces (%20) to various places but without success. Using Ronald’s suggestion
(to be compliant with the documentation) gives another error:
Server cannot process the given uri 'Catalog/SKU' with params 'startswith(SKUNumber,'87840')'.
Does anybody have an idea what is going on here?
I’ve contacted Mendix support and the issue has been solved somewhere between versions 7.13.1 and 7.22.2; with the latest Modeler, the query works fine (with the $filter parameter; they’ve told me they would update the documentation accordingly).
I think you made an error because it should be something like https://www.example.com/odata/Catalog/SKU?startswith(SKUNumber,%2787840%27)
You have to remove the $filter= part.
Did you see this stackoverflow about spaces in OData filters? https://stackoverflow.com/questions/19007765/querying-fields-with-name-containing-whitespace-using-odata