I have written an integration with OneDrive that traverses the user's drives and folders.
I was recently contacted with a bug for a user that had multiple personal drives. Here's what was returned for /me/drives:
GET /me/drives
[0] => Microsoft\Graph\Model\Drive Object
(
[createdDateTime] => 2024-04-16T17:51:30Z
[description] => ****
[id] => b!ZgXcUExgQkiYkeYENuOZof3MA4U_rxRJsnlh9pDBY80Lv2orpc9-PLQ5Lo7FaHMN
[lastModifiedDateTime] => 2024-04-16T17:51:30Z
[name] => OneDrive
[webUrl] => https://my.microsoftpersonalcontent.com/personal/540541d728bc6c6b/AEEE112EFFF94E2C89C603821FF83501
[driveType] => personal
[createdBy] => Array
(
[user] => Array
(
[displayName] => SharePoint App
)
)
[owner] => Array
(
[user] => Array
(
[email] => ****
[displayName] => ****
)
)
[quota] => Array
(
[deleted] => 0
[remaining] => 943174818201
[state] => normal
[total] => 1104880336896
[used] => 161705518695
[storagePlanInformation] => Array
(
[upgradeAvailable] =>
)
)
)
[1] => Microsoft\Graph\Model\Drive Object
(
[createdDateTime] => 2024-04-16T17:51:28Z
[description] =>
[id] => 540541d728bc6c6b
[lastModifiedDateTime] => 2024-04-26T20:24:25Z
[name] => OneDrive
[webUrl] => https://my.microsoftpersonalcontent.com/personal/540541d728bc6c6b/Documents
[driveType] => personal
[createdBy] => Array
(
[user] => Array
(
[displayName] => SharePoint App
)
)
[lastModifiedBy] => Array
(
[user] => Array
(
[displayName] => System Account
)
)
[owner] => Array
(
[user] => Array
(
[email] => ****
[displayName] => ****
)
)
[quota] => Array
(
[deleted] => 0
[remaining] => 943174818201
[state] => normal
[total] => 1104880336896
[used] => 161705518695
[storagePlanInformation] => Array
(
[upgradeAvailable] =>
)
)
)
(Sorry for the redactions and formatting)
I then try to get a listing of the root for each drive.
However, only the second drive above works:
GET /me/drives/540541d728bc6c6b/items/root/children
If I try the first drive:
GET /me/drives/b!ZgXcUExgQkiYkeYENuOZof3MA4U_rxRJsnlh9pDBY80Lv2orpc9-PLQ5Lo7FaHMN/items/root/children
I get:
`GET https://graph.microsoft.com/v1.0/me/drives/b!ZgXcUExgQkiYkeYENuOZof3MA4U_rxRJsnlh9pDBY80Lv2orpc9-PLQ5Lo7FaHMN/root/children?$top=999` resulted in a `400 Bad Request` response:
{"error":{"code":"invalidRequest","message":"ObjectHandle is Invalid","innerError":{"date":"2024-05-01T08:48:55","request-id":"93c593cd-6126-453e-84ba-e4d202cee548","client-request-id":"93c593cd-6126-453e-84ba-e4d202cee548"}}}
Obviously the drive IDs have a different format. I also noticed that even though the drive IDs are different, the webUrl uses the same (working) drive ID.
Is there something different about the first drive that means I shouldn't be trying to read its root listing?