google-api-php-client icon indicating copy to clipboard operation
google-api-php-client copied to clipboard

setOrgUnitId replies success but fails to change anything

Open jwpegram opened this issue 2 years ago • 0 comments

I'm trying to change the orgUnitId of a shared drive. Everything I can find suggests the below code should work but it doesn't. The drive api doesn't throw any errors, the update call returns a 200 but the org is never changed. Any thoughts?

// Create a Google Drive service instance
$service = new Google_Service_Drive($client);

// Specify the shared drive ID you want to modify
$driveId = 'YOUR_SHARED_DRIVE_ID';

// Specify the new orgUnitId
$newOrgUnitId = 'new_org_unit_id';

// Build the request to update the shared drive's orgUnitId
$updateDrive = new Google_Service_Drive_Drive();
$updateDrive->setOrgUnitId($newOrgUnitId);

$optParams = array(
     'useDomainAdminAccess' => true
);

// Update the shared drive with the new orgUnitId
try {
    $drive = $service->drives->update($driveId, $updateDrive);
    echo "Shared drive updated with new orgUnitId: {$drive->getOrgUnitId()}";
} catch (Google_Service_Exception $e) {
    echo "Error updating shared drive: " . $e->getMessage();
}


jwpegram avatar Sep 28 '23 19:09 jwpegram