meum
meum

Reputation: 112

Microsoft Graph: Unable to filter by binary singleValueExtendedProperty

I'm trying to retrieve an event from the grapi api based on a binary extended property that I already have a value for. I have retrieved this value from the same api so I know that an event with this value exists. I also know that the property id is correct since I used this with .Expand() to get the value.

var value = "BAAAAIIA4AB0xbcQGoLgCAAAAAAwMvfBFvzUAQAAAAAAAAAAEAAAAEZ53uCfQ51AhtRf+FNQjOk=";
var cleanGlobalObjectIdPropertyId = "Binary {6ed8da90-450b-101b-98da-00aa003f1305} Id 0x23";

var events = await client.Users["[email protected]"].Events.Request()
    .Filter($"singleValueExtendedProperties/Any(ep: ep/id eq '{cleanGlobalObjectIdPropertyId}' and ep/value eq '{value}')")
    .GetAsync();

This is the error i get:

Microsoft.Graph.ServiceException : Code: ErrorInvalidUrlQueryFilter

Message: The filter expression for $filter does not match to a single extended property and a value restriction.

I have used the same filter syntax with an extended property of type string and that works fine, so I think the fact that this is a binary property is relevant to the problem.

Upvotes: 5

Views: 851

Answers (1)

Dmytro
Dmytro

Reputation: 113

I also faced to this problem. But I try to search for /messages against mapi property SearchKey. I was thinking to use something like:

https://graph.microsoft.com/v1.0/me/messages?$filter=singleValueExtendedProperties%2FAny(ep%3A%20ep%2Fid%20eq%20'Binary%200x300B'%20and%20ep%2Fvalue%20eq%20'yxum+DwfxUy13C4qs5R6ig==')

According to https://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html#_Toc453752358

"The six comparison operators can be used with all primitive values except Edm.Binary, Edm.Stream, and the Edm.Geo types."

So I assume that binary should be casted or decoded from base64 somehow, or it's impossible at all.

UPDATE: So I finally figure it out. Let's say I got the value of singleValueExtendedProperty as:

{
    "id": "Binary 0x300b",
    "value": "yxum+DwfxUy13C4qs5R6ig=="
}

And I wanted to find message by value of this property. The problem here is that '+' should be encoded if exists. Also value should be casted to Edm.Binary. Correct query looks like this:

https://graph.microsoft.com/v1.0/me/messages?$filter=singleValueExtendedProperties%2FAny(ep%3A%20ep%2Fid%20eq%20'Binary%200x300B'%20and%20cast(%20ep%2Fvalue,Edm.Binary)%20eq%20binary'yxum%2BDwfxUy13C4qs5R6ig==')

Upvotes: 1

Related Questions