'Unsupported query while retrieving list of users via Microsoft Graph
I want to retrieve list of specific users who were created before some particular date via Microsoft Graph Explorer.
I am following this Microsoft document : List users - Microsoft Graph v1.0 | Microsoft Docs to form the query.
I tried querying like below:
GET
https://graph.microsoft.com/v1.0/users?$select=createdDateTime, displayName, id, mail&$filter=createdDateTime le 2021-07-14
But I am getting the error as below:
{
"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"
}}}
I have given the required permissions mentioned in the Microsoft document. I am thinking that there is something wrong in my query.
Can anyone help me with the query?
Solution 1:[1]
The reason behind getting the error is, you are filtering only with Date.
To resolve the error, you have to include time along with date like below:
GET https://graph.microsoft.com/v1.0/users?$select=createdDateTime, displayName, id, mail&$filter=createdDateTime le 2021-04-06T08:03:07Z&$count=true
I have tried in my environment and got the list of users successfully with the above query:
Make sure to include Time stamp in below format:
createdDateTime ge yyyy-MM-ddTHH:mm:ssZ
For more in detail, please refer below link:
Azure graph API for users doesn't support filter by createdDateTime anymore - Microsoft Q&A
Solution 2:[2]
Please change your query to:
https://graph.microsoft.com/v1.0/users?$select=createdDateTime, displayName, id, mail&$filter=createdDateTime le 2021-07-14T00:00:00Z
and then you should not get this error.
Basically you will need to specify the date/time value in yyyy-MM-ddTHH:mm:ssZ format.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Gaurav Mantri |

