question

openenergygroup avatar image
0 Votes"
openenergygroup asked JamesHamil-MSFT commented

Graph API - Filtering User by Extended Properties

Hi, we've successfully added extended attributes to our users in a b2c tenant, and a simple query returns a list of users like this:

 https://graph.microsoft.com:443/v1.0/users?$count=true&$select=id,extension_xxxxxxxxxxxxxx_timestamp 

 [
     {
         "id": "0031ce73-e82c-4bf8-9d16-374323fba0eb",
         "extension_xxxxxxxxxxxxxxxx_Timestamp": 1638224961
     }...
 ]

Obviously the extensions are working, because they are shown in the results list.

What we want to do is select where the timestamp is greater than a certain amount. The filter we're using is

 extension_xxxxxxxxxxxxxxxx_Timestamp ge 0

... which should return them all, but is just an empty list. However, even using

 extension_xxxxxxxxxxxxxxxx_Timestamp eq 1638224961

returns an empty list without any error. We've tried setting the $count to be true and header ConsistencyLevel as eventual as suggested for advanced queries, but it's consistently returning no results. In fact, we can't filter using any of our custom attributes, of whatever type.

Query looks like this:

 https://graph.microsoft.com:443/v1.0/users?$count=true&$select=id, extension_xxxxxxxxxxxxxx_timestamp &$filter=extension_xxxxxxxxxxx_Timestamp eq 1638224961

We have tried using the beta api, and we have also tried setting the api permission Directory.AccessAsUser.All as set out in this answer - https://docs.microsoft.com/en-us/answers/questions/403031/graph-api-azure-b2c-filter-for-string-extension-at.html

Thanks











azure-ad-b2cmicrosoft-graph-data-connect
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Neither "1638224961" nor "0" are standard time formats.

0 Votes 0 ·

Thanks, the timestamp field is just a number though (Unix time in seconds). In fact, you only get the choice of string, bool or int.

Fundamentally, I'm not able to filter on any of my extension properties (string or int).

0 Votes 0 ·

Hi @openenergygroup , have you tried testing this with the Graph Explorer?


0 Votes 0 ·

1 Answer

JamesHamil-MSFT avatar image
0 Votes"
JamesHamil-MSFT answered

Hi @openenergygroup , have you tried putting "gt" instead of "ge?" Like this: https://graph.microsoft.com/v1.0/me/messages?$filter=receivedDateTime gt 2016-02-26T14:41:08Z

I took that from this thread. Some of the date filtering can be weird with the API. Please let me know if this works!

Best,
James


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, thanks - no, I think the first thing to resolve is why none of my extension properties is filterable. For instance, I can query all users like this:

 https://graph.microsoft.com:443/beta/users?$select=id,extension_xxxxxxxxxx_teamName

and receive an array like this:

 [
    {
             "id": "0031ce73-e82c-4bf8-9d16-374323fba0af",
             "extension_xxxxxxxxxxxx_TeamName": "My Team"
     }
 ]

.... however, this query, with a simple filter on TeamName is returning empty:

 https://graph.microsoft.com:443/1.0/users?$select=id,extension_xxxxxxxxxxxxxxxx_teamName&$filter=extension_xxxxxxxxxx_TeamName eq 'My Team'


I'm not sure why.















0 Votes 0 ·