How can attributes of an OData-exposed entity be configured to support filtering?

0
I am trying to filter data that I consume from an application exposed through OData, but when I reached the XPath expression section, I received the following error: "Filtering is not supported for attribute X." What is the correct approach to enable filtering on this data
asked
2 answers
0

Hi Carlos,


The error usually means that the attribute is exposed through OData, but it has not been marked as filterable in the published OData service.


In the application that publishes the OData service, open the Published OData Service and edit the entity/attribute you want to filter on.


For the attribute, make sure the Filter capability is enabled.

For example:

Published OData Service
    ↓
Published Entity
    ↓
Edit Published Attribute
    ↓
Capabilities
    ├── Sortable
    └── Filter   ← enable this

Mendix supports the Filter capability at the published-attribute level. This controls whether clients are allowed to use that attribute in an OData $filter expression.

After publishing the change, the consuming application can use a query such as:

/Customers?$filter=Name eq 'John'

For example, if the attribute is Status:

/Customers?$filter=Status eq 'Active'

The important point is that filtering is configured on the OData provider, not on the consuming Mendix application's page or Data Grid.


If the entire OData entity set is marked as non-filterable, then all its attributes will be treated as non-filterable. The same applies if the service exposes metadata indicating that specific properties are non-filterable.

So I would check these two levels:

OData Entity
    ↓
Is the entity/filter capability enabled?
    ↓
Published Attribute
    ↓
Is "Filter" enabled?

Also make sure you are using the exposed attribute name in the OData query. Mendix allows the exposed name of an attribute to be different from its domain-model name.


If you have already enabled Filter for the attribute and still receive the same error, I would refresh/re-import the OData metadata in the consuming application and verify that the generated metadata now marks that property as filterable.


So, in short: enable the Filter capability for that published attribute in the OData provider, republish the service, and then use $filter on the exposed attribute name.


Hope this helps.

answered
0

One thing to verify is whether you're consuming an existing imported OData schema that was generated before the provider enabled filtering.

I've run into cases where the OData service was updated, but the consuming app was still using older metadata. Re-importing or refreshing the OData service document resolved the "Filtering is not supported for attribute ..." message.

Also check whether the attribute's data type is actually supported for filtering by the provider. Even when an attribute is exposed, the service metadata ultimately determines which properties can be used in filter expressions.

If you have access to the provider application, inspect the OData metadata ($metadata) and verify that the attribute is marked as filterable there. If not, the consuming app won't be able to use it in XPath or OData filter expressions regardless of the page configuration.


answered