Google Drive API – How to move shared files within shared folder (PHP -Laravel)?


This Content is from Stack Overflow. Question asked by Sourav Kar

Scenario –

  1. I have created a folder named – “New Folder”.
  2. It has 2 sub folders named – “folder-1” & “folder-2”.
  3. I jhave shared the New folder with another user called John.
  4. John has uploaded 2 files into “folder-1”
  5. Now I want to move those filles from folder-1 to folder-2

I am trying to do it through web app api. whenever I am trying to move it shows this error

- "errors": [
        "domain": "global",
        "reason": "cannotAddParent",
        "message": "Increasing the number of parents is not allowed"

File capabilities - 
"capabilities": GoogleServiceDriveDriveFileCapabilities {#1759 ▼
    +canAcceptOwnership: false
    +canAddChildren: false
    +canAddFolderFromAnotherDrive: null
    +canAddMyDriveParent: false
    +canChangeCopyRequiresWriterPermission: false
    +canChangeSecurityUpdateEnabled: false
    +canChangeViewersCanCopyContent: false
    +canComment: true
    +canCopy: true
    +canDelete: false
    +canDeleteChildren: null
    +canDownload: true
    +canEdit: true
    +canListChildren: false
    +canModifyContent: true
    +canModifyContentRestriction: null
    +canMoveChildrenOutOfDrive: null
    +canMoveChildrenOutOfTeamDrive: null
    +canMoveChildrenWithinDrive: false
    +canMoveChildrenWithinTeamDrive: null
    +canMoveItemIntoTeamDrive: false
    +canMoveItemOutOfDrive: false
    +canMoveItemOutOfTeamDrive: null
    +canMoveItemWithinDrive: true
    +canMoveItemWithinTeamDrive: null
    +canMoveTeamDriveItem: null
    +canReadDrive: null
    +canReadRevisions: true
    +canReadTeamDrive: null
    +canRemoveChildren: false
    +canRemoveMyDriveParent: true
    +canRename: true
    +canShare: true
    +canTrash: false
    +canTrashChildren: null
    +canUntrash: false
    #internal_gapi_mappings: []
    #modelData: array:2 [▶]
    #processed: []


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?