I'm trying to add a single value extended property to a mailFolder in outlook and then retrieve that folder using the property I set. I can create a folder with the extended property, and I can display the extended property using the $expand query parameter so I know it's there, but when I try to retrieve it I get an error.
When I retrieve the mailFolder using the $expand query, this is the response:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('patrick.ivy%40newburnlaw.com')/mailFolders(singleValueExtendedProperties())/$entity",
"id": "AAMkADE5YjAwNzQ3LTc0ZjItNGZhYi1iYTYzLTdkZGYzZmUwMDhiZQAuAAAAAABi_R1_L2WOSbhsPsT-ky8qAQAkYDjZMs8-SbldF0OOgsibAAALsLZ3AAA=",
"displayName": "Test Folder",
"parentFolderId": "AAMkADE5YjAwNzQ3LTc0ZjItNGZhYi1iYTYzLTdkZGYzZmUwMDhiZQAuAAAAAABi_R1_L2WOSbhsPsT-ky8qAQAkYDjZMs8-SbldF0OOgsibAAAAAAEIAAA=",
"childFolderCount": 0,
"unreadItemCount": 0,
"totalItemCount": 0,
"sizeInBytes": 0,
"isHidden": false,
"singleValueExtendedProperties": [
{
"id": "Integer {00000000-0000-0000-0000-000000000001} Name TestProperty",
"value": "1234567"
}
]
}
That tells me the folder exists and that that's the property, right? Here's the API call I'm trying to use to retrieve the folder by extended property (I removed the url encoding so it's easier to read):
https://graph.microsoft.com/v1.0/users/[email protected]/mailFolders?$filter=singleValueExtendedProperties/Any(ep: ep/id eq 'Integer {00000000-0000-0000-0000-000000000001} Name TestProperty' and ep/value eq '1234567')
I based that query off this from the Graph API reference on this page: https://learn.microsoft.com/en-us/graph/api/singlevaluelegacyextendedproperty-get?view=graph-rest-1.0&tabs=http
Specifically, this example:
GET /users/{id|userPrincipalName}/mailFolders?$filter=singleValueExtendedProperties/Any(ep: ep/id eq '{id_value}' and ep/value eq '{property_value}')
but here's the response I get:
{
"error": {
"code": "ErrorInvalidUrlQueryFilter",
"message": "The filter expression for $filter does not match to a single extended property and a value restriction."
}
}
What am I doing wrong?
I believe I have answered my own question, or rather ChatGPT did (Copilot couldn't figure it out). Microsoft does not allow you to $filter on extended properties in mailFolder resources with list operations, in spite of what the API reference says. But, you can list all the folders with their extended properties using $expand, then take that output and filter it on the client side, so that's what I'm going to attempt.