404 Error in "Drive.Files.update"

Asked 2 years ago, Updated 2 years ago, 132 views


To move files within shared drives (team drives) at GAS I try using Drive.Files.update.
I am running with the code below, but there is a 404 error and I am not sure what is wrong.
Is the authentication setting insufficient?
You can also try using APIs Explorer to run it.

function moveFile(){
  varfileId="1-U2N35iiwcz_Q8KXXXXXXXXXXXXXX";
  varsourceFolderId="1gAF-FfwQ0nXXXXXXXXXX";
  vardestFolderId="19wJOjV7XXXXXXXXXXXXXX";

  Drive.Files.update({"fileId":fileId, "addParents":destFolderId, "removeParents":sourceFolderId, "supportAllDrives":true},
    function(err,file){
      if(err){
        Logger.log(err+"file:"+file);
        // Handle error
      } else{
        // File moved.
      }
    });
};

IDI'm masking my ID

google-apps-script google-drive-sdk

2022-09-30 21:42

1 Answers

"It's too late now, but I received advice to post it as ""self-answer"" when I solved myself, so
" I will update here.

It seems to have confused the execution of GAS and Javascript.
It seems that the parameters were not set well.

Drive.Files.update(
   Null//File resource is fine without
  ,fileId//FileId
  Not specified as it is not a ,null//media file
  , {'addParents':destFolderId
   , 'removeParents': sourceFolderId
   , 'supportAllDrives': true // Deprecated but Unspecified Not Found
   } // Specified in Optional query parameters
);


2022-09-30 21:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.