How to use OData query option startswith?

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$filter=SKUNumber%20eq%20%2787840_100%27 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:$filter=startswith(SKUNumber,%2787840%27) This gives me an error: <error xmlns=""> <code>400</code> <message xml:lang="en-US">Unhandled expression type: CallExp</message> </error> I’ve tried to add spaces (%20) to various places but without success. Using Ronald’s suggestion,%2787840%27) (to be compliant with the documentation) gives another error: <error xmlns=""> <code>400</code> <message xml:lang="en-US"> Server cannot process the given uri 'Catalog/SKU' with params 'startswith(SKUNumber,'87840')'. </message> </error>   Does anybody have an idea what is going on here?
2 answers

I think you made an error because it should be something like,%2787840%27)

You have to remove the $filter= part.




Did you see this stackoverflow about spaces in OData filters?


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).