Chris Fellows
Chris Fellows

Reputation: 49

Delete user's files in SharePoint via Graph API

My unattended DotNet Core app (C#) in Azure needs to use Graph API (Graph SDK) to delete a selected AD user's files from OneDrive & SharePoint with a particular file extension where the modified timestamp is at least 90 days ago.

For OneDrive then I get the list of user's drives and then get the relevant drive items. What do I need to do for SharePoint? I assumed that it would be one of the user's drives with driveType="documentLibrary" (i.e. Not "business" or "personal") but I don't find any drives.

Upvotes: 0

Views: 209

Answers (1)

Nikolay
Nikolay

Reputation: 12245

In general, a SharePoint site does not belong to a specific user, it is just a site (that belongs to an organization). However, there is a SharePoint site that does belong to a user, and that is user's "OneDrive".

If you want to delete all files where a specific user is an owner (?), you may need to look through all files in the organization (i.e. on all SharePoint sites in the organization), find the ones where your user is an owner (or creator?) and delete those.

Upvotes: 0

Related Questions