Skip to content

OneDrive/SharePoint — Delete

Type: msfiles-delete  ·  Package: OneDrive / SharePoint v1.0.5

Deletes a file or folder by moving it to the drive’s recycle bin, from where it can be restored in OneDrive or SharePoint during the organization’s retention period.

It works on the session created with OneDrive/SharePoint — Connect. Pass it in the session parameter, or place this activity inside the body of Connect to inherit it automatically.

Deleting a folder also deletes its content. Once deleted, the ID no longer works: if you use it again (for example, when retrying the activity), Microsoft Graph answers itemNotFound. If you retry the delete, treat that error as “already deleted”.

ParameterTypeDefaultDescription
idstring—ID of the file or folder.
ParameterTypeDefaultDescription
sessionZoanMicrosoftFilesSession—Connect session. Inherited inside Connect’s body.

This activity does not return a value.

MessageCause and fix
No OneDrive/SharePoint session available. Provide 'session' from an msfiles-connect activity, or place this activity inside the Connect activity's body so the session is inherited automatically.The activity is outside Connect’s body and did not receive session. Place it inside the body or pass session = session.
'id' is required.id is empty or its expression returned null.
itemNotFound (Microsoft Graph, 404)There is no item with that ID in the session’s drive, or it was already deleted.
accessDenied (Microsoft Graph, 403)The connection has no write permission on the item.
resourceLocked (Microsoft Graph, 423)The file is locked, for example checked out by someone else in SharePoint. Retry later with Retry.

Delete the temporary files in a folder:

OneDrive/SharePoint — Connect credential = credential("m365-operations")
└─ body:
OneDrive/SharePoint — List files folderId = tempFolderId → output: tempFiles
For each t in tempFiles
└─ OneDrive/SharePoint — Delete id = t["id"]