Skip to content

Google Drive — Copy

Type: googledrive-copy  ·  Package: Google Drive v1.0.5  ·  Output: Dictionary<string,object>

Creates a copy of a file in Google Drive. You can choose the copy’s name and the folder it goes to: ideal to produce a new document from a template without touching the original.

Google duplicates the file id on the server (it does not go through the robot’s machine, so it is fast even for large files). By default the copy is called “Copy of …” and stays in the same folder as the original; set name and folderId to change that. Native Google documents are copied as Google documents.

It only copies files: with a folder ID, Google rejects the operation.

ParameterTypeDefaultDescription
idstring—ID of the file to copy.
ParameterTypeDefaultDescription
sessionZoanGoogleDriveSession—Session from Google Drive — Connect. Inside Connect’s body it is inherited and you can leave it empty.
namestring—Name of the copy. If empty, “Copy of …” with the original name.
folderIdstring—Destination folder ID. If empty, the original’s folder.

Returns a Dictionary with the copy’s metadata: copy["id"] is the new ID, different from the original.

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 …Google rejected the call: unknown ID or no access, expired token or quota exceeded. See Google API errors.

Produce the monthly report from a Google Sheets template:

Google Drive — Connect credential = credential("drive-operations")
└─ body:
Google Drive — Copy id = templateId name = "Report " + now().ToString("yyyy-MM")
folderId = reportsId → output: copy
Google Sheets — Open credential = credential("drive-operations") spreadsheetId = copy["id"]
└─ body:
Google Sheets — Write sheet sheet = "Data" values = data