author | ms.author | ms.date | title | ms.localizationpriority |
---|---|---|---|---|
JeremyKelley |
JeremyKe |
09/10/2017 |
List the contents of a folder - OneDrive API |
High |
Return a collection of DriveItems in the children relationship of a DriveItem.
DriveItems with a non-null folder or package facet can have one or more child DriveItems.
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
Permission type | Permissions (from least to most privileged) |
---|---|
Delegated (work or school account) | Files.Read, Files.ReadWrite, Files.Read.All, Files.ReadWrite.All, Sites.Read.All, Sites.ReadWrite.All |
Delegated (personal Microsoft account) | Files.Read, Files.ReadWrite, Files.Read.All, Files.ReadWrite.All |
Application | Files.Read.All, Files.ReadWrite.All, Sites.Read.All, Sites.ReadWrite.All |
GET /drives/{drive-id}/items/{item-id}/children
GET /groups/{group-id}/drive/items/{item-id}/children
GET /me/drive/items/{item-id}/children
GET /sites/{site-id}/drive/items/{item-id}/children
GET /users/{user-id}/drive/items/{item-id}/children
This method supports the $expand
, $select
, $skipToken
, $top
and $orderby
OData query parameters to customize the response.
Name | Value | Description |
---|---|---|
if-none-match | etag | If this request header is included and the eTag (or cTag) provided matches the current tag on the file, an HTTP 304 Not Modified response is returned. |
To retrieve files in the root of the drive, use the root
relationship on the drive, then access the children relationship.
GET /me/drive/root/children
To retrieve files in the root of the drive, use the root
relationship on the drive, then access the children relationship.
GET /drives/{drive-id}/items/{item-id}/children
GET /drives/{drive-id}/root:/{path-relative-to-root}:/children
If successful, this method returns the list of items in the children collection of the target item. The children collection will be composed of driveItem resources.
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{"name": "myfile.jpg", "size": 2048, "file": {} },
{"name": "Documents", "folder": { "childCount": 4} },
{"name": "Photos", "folder": { "childCount": 203} },
{"name": "my sheet(1).xlsx", "size": 197 }
],
"@odata.nextLink": "https://..."
}
Note: If a collection exceeds the default page size (200 items), the @odata.nextLink property is returned in the response to indicate more items are available and provide the request URL for the next page of items.
You can control the page size through optional query string parameters
See Error Responses for more info about how errors are returned.