googleapis / google-api-php-client

A PHP client library for accessing Google APIs
Apache License 2.0
9.2k stars 3.52k forks source link

setOrgUnitId replies success but fails to change anything #2506

Open jwpegram opened 9 months ago

jwpegram commented 9 months ago

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();
}