Nitin Khubani
Nitin Khubani

Reputation: 331

Get delta users (Users creatad between date) - office 365 graph API

I am making a timer job in c# which will make a call to office 365 and fetch newly created users. For example, if I run it now it should fetch users since last run till current time (Delta). However I dont see any FILTER or API parameter where I can pass date and get ONLY those users who are updated or created after specific date.

Is there any API available something like this;

https://graph.windows.net/{MYORG}/users?api-version=1.6&[Filter=createdDate gt 12/12/2016 or modifiedDate gt 12/12/2016]

Upvotes: 2

Views: 2283

Answers (2)

Nitin Khubani
Nitin Khubani

Reputation: 331

I found that blog already however its under delta and throwing errors to me. Here is what I got in response of first call;

https://graph.microsoft.com/beta/users/delta?$skiptoken=

when I did a GET to that link, I am getting error saying the resource you are trying to request is either does not exist or has been removed or...

I feel there is a bug as its beta API.

However, good news is I just found another blog which seems to have be fixed my problem using following query;

https://graph.windows.net/XYZ.onmicrosoft.com/directoryObjects?api-version=1.6&deltaLink=

I will anyway mark your answer as accepted assuming Microsoft will fix the issue I am getting from backend.

Upvotes: 2

juunas
juunas

Reputation: 58823

Azure AD Graph API can't do this as far as I am aware of, the User entity does not contain creation or modification dates to query on.

However, the beta endpoint of the Microsoft Graph API should be able to do this. You can follow the instructions here: https://graph.microsoft.io/en-us/docs/concepts/delta_query_users. Simply put you must:

  1. Call the users endpoint with the delta function
  2. If you got a skip token, it means there are more pages
  3. Fetch the next page until you no longer get a skip token but get a delta token instead
  4. This delta token allows you to call the endpoint anytime later to get only the modified users (created/updated/deleted)

General guidance for delta queries

Upvotes: 2

Related Questions