Skip to content

Latest commit

 

History

History
169 lines (127 loc) · 6.42 KB

File metadata and controls

169 lines (127 loc) · 6.42 KB
author spgraph-docs-team
description Retrieve the metadata for a driveItem in a drive by file system path or ID.
title Get driveItem
ms.localizationpriority medium
ms.subservice onedrive
doc_type apiPageType
ms.date 06/12/2024

Get driveItem

Namespace: microsoft.graph

[!INCLUDE beta-disclaimer]

Retrieve the metadata for a driveItem in a drive by file system path or ID. item-id is the ID of a drive item. It can also be the unique ID of a SharePoint list item.

[!INCLUDE national-cloud-support]

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

[!INCLUDE permissions-table]

[!INCLUDE app-permissions]

Note

The /teams endpoint requires the use of Group.Read.All or Group.ReadWrite.All permissions.

HTTP request

GET /drives/{drive-id}/items/{item-id}
GET /drives/{drive-id}/root:/{item-path}
GET /groups/{group-id}/drive/items/{item-id}
GET /groups/{group-id}/drive/root:/{item-path}
GET /teams/{teamId}/channels/{channelId}/filesFolder
GET /me/drive/items/{item-id}
GET /me/drive/root:/{item-path}
GET /sites/{siteId}/drive/items/{itemId}
GET /sites/{siteId}/drive/root:/{item-path}
GET /users/{userId | userPrincipalName}/drive/items/{item-id}
GET /users/{userId | userPrincipalName}/drive/root:/{item-path}

Optional query parameters

This method supports the $expand and $select OData query parameters to customize the response.

You can use the $expand query string parameter to include the children of an item in the same call as retrieving the metadata of an item if the item has a children relationship.

You can also use the includeDeletedItems=true query parameter to return deleted items. This query parameter is only valid when targeting a driveItem by ID, and otherwise ignored. It's currently only supported on OneDrive Personal.

Optional request headers

Name Value Description
if-none-match String 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.

Response

If successful, this method returns a 200 OK response code and the driveItem resource in the response body.

Example

Request

The following example shows a request to the root folder of the user's OneDrive.

GET /me/drive/root

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


Response

The following example shows the response.

HTTP/1.1 200 OK
Content-type: application/json

{
  "createdBy": {
      "user": {
          "id": "efee1b77-fb3b-4f65-99d6-274c11914d12",
          "displayName": "Ryan Gregg"
      }
  },
  "createdDateTime": "2016-03-21T20:01:37Z",
  "cTag": "\"c:{86EB4C8E-D20D-46B9-AD41-23B8868DDA8A},0\"",
  "eTag": "\"{86EB4C8E-D20D-46B9-AD41-23B8868DDA8A},1\"",
  "folder": { "childCount": 120 },
  "id": "01NKDM7HMOJTVYMDOSXFDK2QJDXCDI3WUK",
  "lastModifiedBy": {
      "user": {
          "id": "efee1b77-fb3b-4f65-99d6-274c11914d12",
          "displayName": "Ryan Gregg"
      }
  },
  "lastModifiedDateTime": "2016-03-21T20:01:37Z",
  "name": "OneDrive",
  "root": { },
  "size": 157286400,
  "webUrl": "https://contoso-my.sharepoint.com/personal/rgregg_contoso_com/Documents"
}

Related content

For details about how errors are returned, see Error responses.