Google Drive — Delete
Google Drive — Delete
Section titled “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.
How it works
Section titled “How it works”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.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | — | File or folder ID. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanGoogleDriveSession | — | Session from Google Drive — Connect. Inside Connect’s body it is inherited and you can leave it empty. |
permanent | bool | false | If true, deletes permanently (cannot be undone); if false, moves it to the trash. |
Output
Section titled “Output”This activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause 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. |
Example
Section titled “Example”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"]Related activities
Section titled “Related activities”- Google Drive — List files — find the items to delete.
- Google Drive — Move — archive instead of deleting.
- Google Drive — Connect — open the session.
- All Google Drive activities