Skip to content

Google Drive — Delete

Type: googledrive-delete  ·  Package: Google Drive v1.0.5  ·  Output: —

Deletes a file or folder. By default it moves it to the trash (recoverable from Drive during Google’s retention period); with permanent it deletes it for good.

With permanent = false it marks the item as trashed: it no longer appears in List files (unless includeTrashed is on) but keeps its ID. Repeating it on an item already in the trash does not fail.

To delete, the account must own the item or have enough edit rights; if it is only shared with you as a reader, Google rejects the operation.

ParameterTypeDefaultDescription
idstring—File or folder ID.
ParameterTypeDefaultDescription
sessionZoanGoogleDriveSession—Session from Google Drive — Connect. Inside Connect’s body it is inherited and you can leave it empty.
permanentboolfalseIf true, deletes permanently (cannot be undone); if false, moves it to the trash.

This activity does not return a value.

MessageCause and fix
'id' is required.id is empty or its expression returned null.
No Google Drive session available. Provide 'session' from a googledrive-connect activity, or place this activity inside the Connect activity's body …The activity is outside Connect’s body and received no session. Move it inside the body or pass the saved session.
The service drive has thrown an exception. HttpStatusCode is Forbidden…The account is neither owner nor editor of the item.
The service drive has thrown an exception. HttpStatusCode is …Google rejected the call: unknown ID or no access, expired token or quota exceeded. See Google API errors.

Send temporary files older than 30 days to the trash:

Google Drive — Connect credential = credential("drive-operations")
└─ body:
Google Drive — List files folderId = tempId
query = "modifiedTime < '" + now().AddDays(-30).ToString("yyyy-MM-ddTHH:mm:ss") + "'"
→ output: old
For Each items = old itemVariable = file
└─ activities:
Google Drive — Delete id = file["id"]