3

How to move a file to trash using NodeJS and Google Drive API v3. Below lines are NOT working:

await drive.files.update({ fileId, trashed: true }); // not working
await drive.files.update({ fileId },  { trashed: true }); // not working
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Sanjay Vamja
  • 2,235
  • 1
  • 16
  • 16

1 Answers1

3

I believe your situation and goal as follows.

  • You want to move a file to the trash box using Drive API v3 with googleapis with Node.js.
  • drive can be used for using the method of "Files: update" of Drive API.

For this, how about this modification? In this case, please include the request body to requestBody or resource as follows.

Modified script:

await drive.files.update({ fileId, requestBody: { trashed: true } });

or

await drive.files.update({ fileId, resource: { trashed: true } });

References:

Tanaike
  • 181,128
  • 11
  • 97
  • 165