I've a WebAPI 2.2 service with OData support.
My controller has an action which returns an IQuerable<Entity>
, but I'm unable to use $filter=substringof
function even if I allow all functions.
[Authorize]
public class MyController : ODataController
{
[EnableQuery(AllowedFunctions=AllowedFunctions.All)]
public IQueryable<Entity> GetEntities()
{
return GetMyQueryable();
}
}
When I hit a URL like http://localhost:49844/Entities/?$filter=substringof('Queen',Name)
I get an error saying substringof is not allowed.
{
"error": {
"code": "",
"message": "The query specified in the URI is not valid. An unknown function with name 'substringof' was found. This may also be a function import or a key lookup on a navigation property, which is not allowed.",
"innererror": {
"message": "An unknown function with name 'substringof' was found. This may also be a function import or a key lookup on a navigation property, which is not allowed.",
"type": "Microsoft.OData.Core.ODataException",
Any idea why I might be seeing this error?
substringof()
is a V3 function while contains()
is a V4 function.
Try contains:
$filter=contains(Name,'Queen')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With