Can't use all or not filter functions with array of primitive types

Joe Thorpe 1 Reputation point
2023-03-01T08:51:52.1233333+00:00

I'm using the /events route (with both v1.0 and beta), and trying to get events which don't have a specific category.

The following $filter queries don't work:

not(categories/any(c:c eq 'Tracked to Dynamics 365')) => "An internal server error occurred. The operation failed."

This filter is documented here: https://learn.microsoft.com/en-us/graph/filter-query-parameter?tabs=http#:~:text=~/groups%3F%24filter%3Dnot(groupTypes/any(c%3Ac%20eq%20%27Unified%27))*

categories/all(c:c ne 'Tracked to Dynamics 365') => "The query filter contains one or more invalid nodes."

This filter is documented here: https://learn.microsoft.com/en-us/graph/filter-query-parameter?tabs=http#all-operator

not categories/any(c:c eq 'Tracked to Dynamics 365') => "An internal server error occurred. The operation failed."

This filter is documented as an advanced query with the ConsistencyLevel: eventual header. I don't think this entity supports advanced queries, so i don't expect this one to work.

I would expect the first two filters to work.

Just to see if any collection functions work, i tried the following filter, which does work (i.e. the request returns results).

categories/any(c:c ne 'Tracked to Dynamics 365')

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,449 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-03-02T08:10:50.53+00:00

    Hi @Joe Thorpe ,

    Thanks for reaching out!

    As per the documentation filter collection complex types, the suggested way for filtering not equal is not(categories/any(c:c eq 'Orange category')

    I am able to return results by using this query $filter=not(categories/any(c:c eq 'Orange category')) by applying filtering on me/messages endpoint.

    But for me/events as you mentioned it is working with $filter=categories/any(c:c ne 'Orange category').

    Unlike this isn't an expected behavior, I would suggest you submit request in https://aka.ms/graphfeedback or you can raise support ticket from 
    http://aad.portal.azure.com/ or https://admin.microsoft.com/#/support/requests.

    Hope this helps.

    If the reply is helpful, please click "Accept Answer" and kindly upvote it. If you have additional questions about this answer, please click "Comment".

    0 comments No comments