Issue with DELTA query on list-items not returning 'deleted' items

Vikharankar, Vishakha 25 Reputation points
2023-11-10T08:48:14.41+00:00

I'm using the GET /sites/{siteId}/lists/{listId}/items/delta API in Graph Explorer, following the documentation at https://learn.microsoft.com/en-us/graph/api/listitem-delta?view=graph-rest-beta&tabs=http. However, I've noticed that the API isn't returning any records of 'deleted' items, unlike what's shown in the example at https://learn.microsoft.com/en-us/graph/api/listitem-delta?view=graph-rest-beta&tabs=javascript#response-2. I was previously able to get 'deleted' items with this API a few days ago. Has something changed?

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Joel Moser 5 Reputation points
    2025-01-02T15:29:48.1933333+00:00

    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 the GET /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.
    1 person found this answer helpful.
    0 comments No comments

  2. RaytheonXie_MSFT 40,476 Reputation points Microsoft External Staff
    2023-11-13T05:49:36.68+00:00

    Hi @Vikharankar, Vishakha,

    When using delta query Microsoft Graph returns as deleted new/updated/deleted items that are not in start-end date range of the initial request.

    Please check if you have this issue in the case. Here is the document for tracking changes

    https://learn.microsoft.com/en-us/graph/delta-query-overview


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.