I'm trying to filter users by attributes in Microsoft Graph API. Essentially trying to get a list of users that have a given jobTitle assigned.
For example, https://graph.microsoft.com/v1.0/users?$filter=jobtitle eq 'ACCOUNT EXECUTIVE' returns a list of users.
My requirement is to query for users that do not have a JobTitle.
Tried https://graph.microsoft.com/v1.0/users?$filter=jobtitle ne null and got the following message.
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported property filter clause operator 'NotEqualsMatch'.",
"innerError": {
"request-id": "c9b290bf-2902-4b79-b35b-0f5d251ad80b",
"date": "2017-09-14T11:18:52"
}
}
}
$filter=department ge '!' appears to be a workaround here.
According to this Git Issue, I don't think it's supported: https://github.com/microsoftgraph/microsoft-graph-docs/issues/239 (it eventually just revolves around finding rooms)
There is no way to filter the users collection for entities with surname equal to null or empty string. The value of the filter must be between 1 and 64 characters as documented here: https://msdn.microsoft.com/en-us/Library/Azure/Ad/Graph/api/entity-and-complex-type-reference#userentity - marych Apr 26, 2016
The lack of null filtering is due to the way users are indexed. We can't efficiently retrieve users with an indexed property unset. There are no plans to change that. - marych May 13, 2016
Related
I am trying to simplify a GraphAPI request to get a list of mail folders based on a displayName filter. This seems to work with the eq operator but not with in. Below are the two requests, which should return the same result.
Using eq:
https://graph.microsoft.com/v1.0/me/mailfolders?$filter=displayName eq 'inbox' or displayName eq 'drafts'
Using in:
https://graph.microsoft.com/v1.0/me/mailfolders?$filter=displayName in ('inbox', 'drafts')
When using in I get the error below:
{
"error": {
"code": "ErrorInvalidUrlQueryFilter",
"message": "The query filter contains one or more invalid nodes.",
"innerError": {
"date": "2022-02-16T16:48:51",
"request-id": "",
"client-request-id": ""
}
}
}
From the documentation I've read in should be supported wherever eq is supported by default. Syntax should be correct based on examples I found here: https://learn.microsoft.com/en-us/graph/query-parameters#examples-using-the-filter-query-operator
Can someone shed some light on what the issue might be?
Your last statement applies only to directory objects (resources that are documented as inheriting from the directoryObject resource.
mailFolder isn't one of them
for inbox for example, you can use directly this:
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox
Source: https://learn.microsoft.com/en-us/graph/api/resources/mailfolder?view=graph-rest-1.0
According to the MS Graph API documentation, businessPhones are supported to be used in a $filter query with eq comparison, just like the imAddresses property.
When inspecting Microsoft's use query parameters documentation, there's an example where the imAddresses property is used in a collection filter and it works just fine.
GET https://graph.microsoft.com/v1.0/users?$filter=imAddresses/any(s:s eq 'admin#contoso.com')
My goal ist to list all users that have a specific phone number in their businessPhones collection property.
However, when I try to use the businessPhones property in a similar query, the query does not work as expected.
GET https://graph.microsoft.com/v1.0/users?$filter=businessPhones/any(s:s eq '1234')
Status code: 400
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'businessPhones' of resource 'User'.",
"innerError": {
"date": "2021-07-30T08:07:24",
"request-id": "ac3923be-de11-448f-b2b5-245edc82d20e",
"client-request-id": "ac3923be-de11-448f-b2b5-245edc82d20e"
}
}
}
Any ideas on what I am missing?
You need to use advanced query capabilities, which means you need to add a $count=true query string parameter and a ConsistencyLevel=Eventual header to your request.
Can anybody tell me how to get a list of just files in a particular folder on OneDrive using Microsoft Graph API? I believe I found an approach I have to use but either I don't understand something or it is impossible. I can get a list of children items in a folder. I can use $filter=folder ne null to get just a list of folders but I don't understand how to get a list of files. If I negate the expression, make it $filter=folder eq null it gives me an error. I tried many other possible expressions like $filter=file ne null, $filter=size ne 0 even though it is not exactly a filter for files a files can be 0 size but anyway it gives an error as well.
Update:
Tested in a test tool. It gives
{
"error": {
"code": "invalidRequest",
"message": "Invalid request",
"innerError": {
"date": "2021-02-23T06:25:08",
"request-id": "4d1903d3-d989-4d90-8130-479ac1b24af2",
"client-request-id": "4d1903d3-d989-4d90-8130-479ac1b24af2"
}
}
for this query
https://graph.microsoft.com/v1.0/me/drive/root/children$filter=folder eq null
Here is the link to the tool
https://developer.microsoft.com/en-us/graph/graph-explorer
I'm trying to $expand on singleValueExtendedProperties for a delta query on my messages, but I'm getting an odd error.
Delta query
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages/delta?$expand=singleValueExtendedProperties($filter=id eq 'String 0x007D')
Response
{
"error": {
"code": "InternalServerError",
"message": "Value cannot be null.\r\nParameter name: type",
"innerError": {
"request-id": "d7cf6c83-a062-4051-85b4-30a5aadf2e65",
"date": "2017-10-06T10:05:10"
}
}
}
The documentation says this is supported. I've also verified (via the GraphAPI explorer) that:
the non-delta version of the query works with singleValueExtendedProperties
the delta version works without singleValueExtendedProperties
Is this a bug in the API or expected behavior? I know I can follow up with multiples GETs to pull the desired extended properties, but I'd rather avoid spawning several requests if I can get away with one.
There is limited support for the $filter query parameter on messages/delta. From the documentation:
The only supported $filter expresssions are $filter=receivedDateTime+ge+{value} or $filter=receivedDateTime+gt+{value}.
I'm trying to user the contains filter on a /users query, like this for example:
https://graph.microsoft.com/v1.0/users?$filter=contains(displayName, 'Garth')
However, this results in a BadRequest response saying "An unknown function with name 'contains' was found. This may also be a key lookup on a navigation property, which is not allowed."
According to the OData 4.0 specs, the contains filter should be available though. Is there a way to use a contains filter on a list of users?
The contains function is not available for users. startsWith is available though.
e.g. https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'Garth').
Additionally you can try the people API (this is only available on /beta). This supports $search AND will do fuzzy and phonetic matching.
https://graph.microsoft.com/beta/me/people?$search=Garth
$search can replace $contains
for example to show all the users that their names may contain the string "sa"
https://graph.microsoft.com/v1.0/users?$count=true&$search="givenName:sa"
"value": [
{....
"givenName": "Sammy",
.....
},
{
.....
"givenName": "Sabrina",
.......
},
.....