drive: sharedWithMe

Namespace: microsoft.graph

Important

APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.

Get a list of driveItem objects shared with the owner of a drive.

The driveItems returned from the sharedWithMe method always include the remoteItem facet that indicates they're items from a different drive.

This API is available in the following national cloud deployments.

Global service US Government L4 US Government L5 (DOD) China operated by 21Vianet

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.

Permission type Least privileged permissions Higher privileged permissions
Delegated (work or school account) Files.Read.All Files.ReadWrite.All, Sites.Read.All, Sites.ReadWrite.All
Delegated (personal Microsoft account) Files.Read.All Files.ReadWrite.All
Application Not supported. Not supported.

Note:

  • A /sharedWithMe request succeeds with Files.Read or Files.ReadWrite permissions; however, some properties might be missing.
  • You can't access shared items returned from this API if the request doesn't contain one of the *.All permissions.

HTTP request

GET /me/drive/sharedWithMe

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.

Request body

Don't supply a request body for this method.

Response

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

By default, this method returns items shared within your own tenant. To include items shared from external tenants, append ?allowexternal=true to a GET request.

Examples

Example 1: Get driveItems shared with me

The following example gets a collection of driveItem resources that are shared with the owner of the drive.

Request

The following example shows a request.

GET https://graph.microsoft.com/beta/me/drive/sharedWithMe

Response

The following example shows the response that returns items shared with the signed-in user, because the drive is the user's default drive.

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

{
  "value": [
    {
      "id": "1312abc",
      "remoteItem": {
        "id": "1991210caf!192",
        "name": "March Proposal.docx",
        "file": { },
        "size": 19121,
        "parentReference": {
          "driveId": "1991210caf",
          "id": "1991210caf!104"
        }
      }
    },
    {
      "id": "1312def",
      "remoteItem": {
        "id": "1991210caf!1991",
        "name": "Team Roster.xlsx",
        "file": { },
        "size": 37619,
        "parentReference": {
          "driveId": "1991210caf",
          "id": "1991210caf!104"
        }
      }
    },
    {
      "id": "1312ghi",
      "remoteItem": {
        "id": "987def!654",
        "name": "January Service Review.pptx",
        "file": { },
        "size": 145362,
        "parentReference": {
          "driveId": "987def",
          "id": "987def!321"
        }
      }
    }
  ]
}

Example 2: Get metadata about a shared driveItem object

The following example shows how to access metadata about the shared driveItem with the name January Service Review.pptx that requires a request using the driveId of the parentReference within the remoteItem object.

Request

The following example shows a request.

GET https://graph.microsoft.com/beta/drives/987def/items/987def!654

Response

The following example shows the response.

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

{
  "id": "987def!654",
  "name": "January Service Review.pptx",
  "file": { },
  "size": 145362,
  "parentReference": {
    "driveId": "987def",
    "id": "987def!321"
  }
}