在 MS Graph 中按日期过滤对象对象、按日、MS、Graph

2023-09-07 09:04:27 作者:于你悸动

I'm trying to get a list of all users who were created after a certain date.

I can use the endpoint below to get all users and then extend it again to request the user created date. In the graph explorer this only shows my date the rest are blank but I'm guessing this is down to permissions so I'm not concerned as this will be running in an SPFx web part with requested Graph permissions

Graphpad作折线图

https://graph.microsoft.com/v1.0/users

https://graph.microsoft.com/v1.0/users?$select=id, displayName, jobTitle, createdDateTime

Regardless of any filter I enter, see examples below, I never get any response on an error saying "Syntax error at position 26 in 'createdDateTime gt 2018-08-02T13:01:13Z'"

https://graph.microsoft.com/v1.0/users?$select=id, displayName, jobTitle, createdDateTime&$filter= createdDateTime gt 2018-01-01

https://graph.microsoft.com/v1.0/users?$select=id, displayName, jobTitle, createdDateTime&$filter= createdDateTime gt 2018-08-02T13:01:13Z

I want to be able to find all users created after a certain date but can't filter the user results on this date property it only works with basic details like displayName eq 'Raymond Little'

解决方案

Unfortunately, filtering by createdDateTime is not currently supported on this resource type. We plan to add it in the future, but cannot share an ETA, yet.

You would have to fetch the full user collection and filter out locally.

If your scenario is about finding net new users that have been created, consider using the delta query capability. It allows you to efficiently pick up newly created resources.

https://docs.microsoft.com/en-us/graph/delta-query-overview