I had this exact same problem and finally found a solution. It is a nuance with the difference between the listItem
and driveItem
APIs. Basically the delta query for the driveItem
API gives you the information you need that the listItem
delta query is lacking.
However, there is a caveat to the way that you call the driveItem
delta query. The API documentation says that you can do a GET /sites/{siteId}/drive/root/delta
to fetch the changes to the driveItems in a given site. But that doesn't seem to always return all of the data you need (or doesn't actually track all of the changes properly). When you call the same drive delta API with GET /drives/{drive-id}/root/delta
, it returns all of the information you need for handling deleted data. It returns a deleted state and the relevant parent reference information to ensure you can properly identify that item in your system.
Here is a link to the documentation for reference: https://learn.microsoft.com/en-us/graph/api/driveitem-delta?view=graph-rest-1.0&tabs=http
Some other notes that were relevant for my use case:
- If you need the
listItem
information (for processing non-deletes) you can always use?$expand=listItem
to get that information. - If you don't know the
drive-id
for your site, just a simple fetch to theGET /sites/{siteId}
endpoint with a?$expand=drive
query param will give you the drive information you need to call the drive delta query. You can also use that query param on the sites list query.