I've got a search to find documents in SharePoint online document libraries not updated within a specific time frame. It's returning what I kind of expect.
POST https://graph.microsoft.com/v1.0/search/query
Request Body
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "LastModifiedTime<2022-09-15 isDocument:true"
},
"fields": [
"title",
"UniqueId",
"id",
"ListID",
"Filename",
"IsDocument",
"FileExtension",
"WebUrl",
"SiteID",
"WebId",
"Author",
"LastModifiedTime"
]
}
]
}
example of "resource" section of results:
{
"@odata.type": "#microsoft.graph.listItem",
"fields": {
"title": "PowerPoint Template - Widescreen Size",
"uniqueId": "{3BE7714A-EA2D-4B32-A66A-CFCE28C9zzzz}",
"id": "AAAAAGaLPIjzUfFNrdwtmY6ZKr4HAGjxE0Vl4dxOpU2hoI6JGDgAAAAAAScAAGjxE0Vl4dxOpU2hoI6JGDgAAOWu4t0AAA2",
"listID": "a3accbde-26ed-4dab-9e24-8f5548ec8462",
"filename": "Info for Microsoft 365_Labelingupdate_050322.pptx",
"isDocument": true,
"fileExtension": "pptx",
"siteID": "13c96220-50e5-4397-bfb9-cf72259fxxxx",
"webId": "6e83fd9c-60db-40bc-82ff-11f1eb46yyyy",
"author": "Stan Spotts",
"lastModifiedTime": "2022-05-13T19:59:33Z"
}
The Graph API for delete doesn't find the file no matter what Id I try. For instance, this:
DELETE https://graph.microsoft.com/v1.0/sites/13c96220-50e5-4397-bfb9-cf72259fxxxx/drive/items/3BE7714A-EA2D-4B32-A66A-CFCE28C9zzzz
results in:
"code": "itemNotFound",
"message": "The resource could not be found."
Am I using the delete API incorrectly, or is it that the search API doesn't return the information I need for calling the delete API?
Please, no need to tell me about retention policies. This is a simplified search.