An API that connects multiple Microsoft services, enabling data access and automation across platforms
The 422 response and the message Children cannot be listed from an item that is not a folder are expected when using $expand=children on a driveItem that represents a file rather than a folder.
The OneDrive/Graph driveItem model only exposes a children relationship for items that have a non-null folder (or package) facet. Files do not have children, so attempting to expand or list children on a file now correctly returns an error instead of silently succeeding.
To fix the issue:
- Ensure that
$expand=childrenis used only when the target driveItem is a folder (or package):- First get the item metadata without expand:
GET /drives/{drive-id}/items/{item-id} - Check that the response has a non-null
folderfacet before calling with$expand=childrenor before calling/children.
- First get the item metadata without expand:
- For folders, use one of the supported patterns:
- Get folder metadata and children in one call using
$expand=children:
(Only valid if the item is a folder.)GET /drives/{drive-id}/items/{folder-item-id}?$expand=children - Or list children directly:
GET /drives/{drive-id}/items/{folder-item-id}/children
- Get folder metadata and children in one call using
- For files, remove
$expand=childrenentirely, because files cannot have children. Use a simple GET:GET /drives/{drive-id}/items/{file-item-id}
If this previously “worked” on a file driveItem, the behavior was likely permissive or inconsistent and has since been corrected to enforce the documented rule that only folder/package items can have children.
References: