I am using the OneDrive API in PHP and I retrieve the following list of drives for a user using /me/drives
:
<code>(
[0] => MicrosoftGraphModelDrive Object
(
[_propDict:protected] => Array
(
[createdDateTime] => 2024-04-16T17:51:30Z
[description] => Desc1
[id] => b!ZdXcWExgQkiKkeYEMuOZof1MA3U_rxRJsnbh9pDQY80Lv8orpc9-RLQ0Lo7FaHPN
[lastModifiedDateTime] => 2024-04-16T17:51:30Z
[name] => OneDrive
[webUrl] => https://my.microsoftpersonalcontent.com/personal/???/???
[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] => MicrosoftGraphModelDrive Object
(
[_propDict:protected] => Array
(
[createdDateTime] => 2024-04-16T17:51:28Z
[description] =>
[id] => 740141a789bd6c6a
[lastModifiedDateTime] => 2024-04-22T22:56:29Z
[name] => OneDrive
[webUrl] => https://my.microsoftpersonalcontent.com/personal/???/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] =>
)
)
)
)
)
</code>
<code>(
[0] => MicrosoftGraphModelDrive Object
(
[_propDict:protected] => Array
(
[createdDateTime] => 2024-04-16T17:51:30Z
[description] => Desc1
[id] => b!ZdXcWExgQkiKkeYEMuOZof1MA3U_rxRJsnbh9pDQY80Lv8orpc9-RLQ0Lo7FaHPN
[lastModifiedDateTime] => 2024-04-16T17:51:30Z
[name] => OneDrive
[webUrl] => https://my.microsoftpersonalcontent.com/personal/???/???
[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] => MicrosoftGraphModelDrive Object
(
[_propDict:protected] => Array
(
[createdDateTime] => 2024-04-16T17:51:28Z
[description] =>
[id] => 740141a789bd6c6a
[lastModifiedDateTime] => 2024-04-22T22:56:29Z
[name] => OneDrive
[webUrl] => https://my.microsoftpersonalcontent.com/personal/???/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] =>
)
)
)
)
)
</code>
(
[0] => MicrosoftGraphModelDrive Object
(
[_propDict:protected] => Array
(
[createdDateTime] => 2024-04-16T17:51:30Z
[description] => Desc1
[id] => b!ZdXcWExgQkiKkeYEMuOZof1MA3U_rxRJsnbh9pDQY80Lv8orpc9-RLQ0Lo7FaHPN
[lastModifiedDateTime] => 2024-04-16T17:51:30Z
[name] => OneDrive
[webUrl] => https://my.microsoftpersonalcontent.com/personal/???/???
[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] => MicrosoftGraphModelDrive Object
(
[_propDict:protected] => Array
(
[createdDateTime] => 2024-04-16T17:51:28Z
[description] =>
[id] => 740141a789bd6c6a
[lastModifiedDateTime] => 2024-04-22T22:56:29Z
[name] => OneDrive
[webUrl] => https://my.microsoftpersonalcontent.com/personal/???/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] =>
)
)
)
)
)
Both drives are personal
.
I select one of them (let’s say the first) and try to list the contents:
<code>GET https://graph.microsoft.com/v1.0/me/drives/b!ZdXcWExgQkiKkeYEMuOZof1MA3U_rxRJsnbh9pDQY80Lv8orpc9-RLQ0Lo7FaHPN/items/root/children?$top=999
</code>
<code>GET https://graph.microsoft.com/v1.0/me/drives/b!ZdXcWExgQkiKkeYEMuOZof1MA3U_rxRJsnbh9pDQY80Lv8orpc9-RLQ0Lo7FaHPN/items/root/children?$top=999
</code>
GET https://graph.microsoft.com/v1.0/me/drives/b!ZdXcWExgQkiKkeYEMuOZof1MA3U_rxRJsnbh9pDQY80Lv8orpc9-RLQ0Lo7FaHPN/items/root/children?$top=999
However I get:
<code>{
"error": {
"code": "invalidRequest",
"message": "ObjectHandle is Invalid",
"innerError": {
"date": "2024-04-23T09:48:26",
"request-id": "7da7ea84-88ba-4bc9-a9fd-4a547eca49f1",
"client-request-id": "7da7ea84-88ba-4bc9-a9fd-4a547eca49f1"
}
}
}
</code>
<code>{
"error": {
"code": "invalidRequest",
"message": "ObjectHandle is Invalid",
"innerError": {
"date": "2024-04-23T09:48:26",
"request-id": "7da7ea84-88ba-4bc9-a9fd-4a547eca49f1",
"client-request-id": "7da7ea84-88ba-4bc9-a9fd-4a547eca49f1"
}
}
}
</code>
{
"error": {
"code": "invalidRequest",
"message": "ObjectHandle is Invalid",
"innerError": {
"date": "2024-04-23T09:48:26",
"request-id": "7da7ea84-88ba-4bc9-a9fd-4a547eca49f1",
"client-request-id": "7da7ea84-88ba-4bc9-a9fd-4a547eca49f1"
}
}
}
This seems to work when the user only has one drive.
I also trying URL encoding the drive ID but it doesn’t make any difference.
Is there a problem with how I’m defining the root folder?