我想检索在某个特定日期之前通过 Microsoft Graph Explorer 创建的特定用户的列表。
我正在关注此 Microsoft 文档:List users - Microsoft Graph v1.0 | Microsoft Docs形成查询。
我尝试像下面这样查询:
GET
https://graph.microsoft.com/v1.0/users?$select=createdDateTime, displayName, id, mail&$filter=createdDateTime le 2021-07-14
但是我收到如下错误:
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'createdDateTime' of resource 'User'.",
"innerError": {
"date": "2022-05-12T14:24:38",
"request-id": "5378dd7c-7413-4b97-9399-09a6f4f11c50",
"client-request-id": "ba9f70f4-f33c-c753-fb3a-c6f1a197ef46"
}}}
我已授予 Microsoft 文档中提到的所需权限。我认为我的查询有问题。
有人可以帮我解决这个问题吗?
最佳答案
出现错误的原因是,您仅使用日期进行过滤。
要解决该错误,您必须包含时间以及日期,如下所示:
GET https://graph.microsoft.com/v1.0/users?$select=createdDateTime, displayName, id, mail&$filter=createdDateTime le 2021-04-06T08:03:07Z&$count=true
我在我的环境中进行了尝试并通过上述查询成功获取了用户列表:
确保包含以下格式的时间戳:
createdDateTime ge yyyy-MM-ddTHH:mm:ssZ
欲了解更多详情,请引用以下链接:
Azure graph API for users doesn't support filter by createdDateTime anymore - Microsoft Q&A
关于azure - 通过 Microsoft Graph 检索用户列表时不支持查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72219313/