question

MaluendaMirandaCristianG-8363 avatar image
0 Votes"
MaluendaMirandaCristianG-8363 asked Patrik-4770 commented

Azure graph API for users doesn't support filter by createdDateTime anymore

Hi,
We have a job that searches the users created between two dates. It was working fine until the last week. Suddenly, Microsoft decided to not support filters by "createdDateTime" for Users anymore, despite the documentation says it is supported (https://docs.microsoft.com/en-us/graph/api/resources/user?view=graph-rest-1.0).

Now, our job is broken and I need to find a walkaround to search the users created daily. I am not sure if the delta link will help me, because the job is stateless.

Regards,
Cristian.

microsoft-graph-users
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.

MaluendaMirandaCristianG-8363 avatar image
1 Vote"
MaluendaMirandaCristianG-8363 answered Patrik-4770 commented

Microsoft fixes this issue, but it doesn't support just the date. It is necessary to include the time.
Here is an example:

https://graph.microsoft.com/v1.0/users?$filter=(createdDateTime ge 2021-07-01T00:00:00Z AND createdDateTime le 2021-08-01T00:00:00Z)


It is not necessary to use any advanced query parameters!

· 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,
I can confirm that my use case is now working again.
Thanks!
Patrik Rosquist

0 Votes 0 ·
Pras12-3120 avatar image
0 Votes"
Pras12-3120 answered MaluendaMirandaCristianG-8363 commented

Please try this, I used your command and modified it a bit. It worked for me.


https://graph.microsoft.com/v1.0/users?$filter=(createdDateTime ge 2021-07-01T00:00:00Z AND createdDateTime le 2021-08-01T00:00:00Z)&$count=true

Make sure you're passing the header (ConsistencyLevel) as well.

· 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.

Thanks Pras for your answer. My problem is Azure AD B2C does not support advanced query parameters. So, this will not work for me :(

0 Votes 0 ·
MaluendaMirandaCristianG-8363 avatar image
0 Votes"
MaluendaMirandaCristianG-8363 answered MaluendaMirandaCristianG-8363 edited

This is getting worst!
I tried to loop over the users and filter them out in my code.
When we are iterating over all the users using paging (https://docs.microsoft.com/en-us/graph/paging), we get this error:

status: 414,
 statusText: 'URI Too Long',

In summary, there is not any way to get the users between two dates!


Update:

The problem was I added to the request the query parameter select in each call, and Azure Graph API was appending the same values to the query parameter all the time. So, the URI grew until Azure threw the error.
I believe this wasn't the behavior before the change, but I can't prove it.

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.

ssk-4704 avatar image
0 Votes"
ssk-4704 answered Pras12-3120 commented

Hi @Danstan

I'm also having the same exact problem even by using the advanced query options.

Any ideas ?

· 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.

Please try the answer I posted, it worked for me.

0 Votes 0 ·
MaluendaMirandaCristianG-8363 avatar image
0 Votes"
MaluendaMirandaCristianG-8363 answered Danstan-MSFT commented

Thanks, Danstan for your answer.
I tried to use the advance query option, as you suggested, but I got the same error:
"Unsupported or invalid query filter clause specified for property 'createdDateTime' of resource 'User'."

Something that I don't understand is, I am using the operators "ge" and "le" and the documentation says those operators are supported by default.

Summary, my filter "(createdDateTime ge 2021-07-28 AND createdDateTime le 2021-07-29)" doesn't work using the default or advance query parameter.

· 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.

I am having the exact same problem. Our service stopped working 2021-07-30 20:50. Also tried the above suggestions and still no luck.
Then I found that the "Advanced Query Options" are not supported for Azure AD B2C tenants from link above.
So how to get around this?

Regards,
Patrik

0 Votes 0 ·
Danstan-MSFT avatar image
1 Vote"
Danstan-MSFT answered McDermidJosh-3288 commented

The filter requires the Advanced Query Options.

To get it to work you need to add the count operator and the ConsistencyLevel=eventual. Example

 GET https://graph.microsoft.com/v1.0/users?$filter=createdDateTime eq 2021-04-06T08:03:07Z&$count=true
 ConsistencyLevel: eventual


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

· 10
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.

@maluendamirandacristiang-8363 Try the query above on Graph Explorer and ensure you add the header ConsistencyLevel: eventual and count=true query option then share the error if you get one. This query works on my end.

0 Votes 0 ·

Can you try the query with full DateTime value like: The query below works on my end with the header
GET /users?$filter=(createdDateTime ge 2021-04-06T08:03:07Z AND createdDateTime le 2021-04-06T08:03:07Z)&$count=true



0 Votes 0 ·

It didn't work. I got the same error. I am in the same situation as @Patrik-4770, I am using Azure AD B2C.

1 Vote 1 ·
Show more comments