To filter Microsoft Graph API responses, the docs suggest to use the filter query option.
Here I've used startswith and endswith string functions on the '/me/messages' endpoint.
query = {
'$filter': "
startswith(from/emailAddress/address, 'abcd')
or endswith(from/emailAddress/address, 'gmail.com')"
}
Only using startswith returns the expected response. On adding the endswith function to the filter query, the response received is an error.
{
"error": {
"code": "ErrorInvalidUrlQueryFilter",
"message": "The query filter contains one or more invalid nodes.",
"innerError": {
"request-id": "0d12e1f6-6105-4826-9656-8613f8c167ed",
"date": "2019-03-14T11:05:56"
}
}
}
They haven't implemented the full OData spec (and probably never will) so the endswith option to filter is not currently supported for any of their endpoints.
From the docs:
The startswith string operator is often supported. The any lambda operator is supported for some APIs.
Read that as "The only filter options that we've implemented are startswith and any, and even then their use is limited to a subset of endpoints".
It would be nice if they could also list the endpoints on which those options were valid, but you don't get to >600 open issues if you have a properly sized staff that actually fixes problems.
Despite many upvotes in UserVoice, the filters like "endswith" are still unsupported. For example, even if the latest Microsoft doc( updated on 10/06/2020) itself says the 'endswith' filter works for the /user endpoint, it is just not true. The given example doesn't work at all, "Unsupported query" is still/simply returned by both 1.0 and beta endpoints. Trying it on various tenants, the same. Could the MS product team put their feet in the shoes of those who are doing daily admin job in very large organizations?
Get all users with mail domain equal to 'hotmail.com' | https://graph.microsoft.com/v1.0/users?$count=true&$filter=endsWith(mail,'@hotmail.com')
It has been more than one year since this issue is raised but still this 'endswith' query parameter issue has not resolved. I have started using this OData query parameter but forun out there are many limitations and when tried to search user from organization it doesn't work at all. Can anyone from the team provide a quick permanent fix to this issue ?
bumping
still waiting for "endsWith" to work!
@thejazz15 @cendern did you guys find a work around?
what about using $search?
someone want to try to master the query language for this?
Most helpful comment
They haven't implemented the full OData spec (and probably never will) so the
endswithoption tofilteris not currently supported for any of their endpoints.From the docs:
Read that as "The only
filteroptions that we've implemented arestartswithandany, and even then their use is limited to a subset of endpoints".It would be nice if they could also list the endpoints on which those options were valid, but you don't get to >600 open issues if you have a properly sized staff that actually fixes problems.