Microsoft Graph returns 422 when using $expand=children on a file driveItem

Nguyễn Liễu 10 Reputation points
2026-03-17T10:08:50.12+00:00

I call the API GET https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{driveItem-id}?$expand=children where the driveItem-id belongs to a file.

Yesterday the request worked normally, but today it returns a 422 error as shown below.

{
    "error": {
        "code": "notSupported",
        "message": "Children cannot be listed from an item that is not a folder",
        "innerError": {
            "code": "unprocessableEntity",
            "innerError": {
                "code": "getChildrenOnNonFolder"
            },
            "date": "2026-03-17T08:46:29",
            "request-id": "83a946e0-784c-469e-8cc0-c881ba0cfb3c",
            "client-request-id": "83e7345c-0746-e5bd-e718-73c2be348f9c"
        }
    }
}
Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Newest
  1. AI answer

    2026-03-17T10:09:06.8533333+00:00

    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:

    1. Ensure that $expand=children is 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 folder facet before calling with $expand=children or before calling /children.
    2. For folders, use one of the supported patterns:
      • Get folder metadata and children in one call using $expand=children:
             GET /drives/{drive-id}/items/{folder-item-id}?$expand=children
        
        (Only valid if the item is a folder.)
      • Or list children directly:
             GET /drives/{drive-id}/items/{folder-item-id}/children
        
    3. For files, remove $expand=children entirely, 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:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.