Skip to content

Latest commit

 

History

History
220 lines (165 loc) · 7.94 KB

File metadata and controls

220 lines (165 loc) · 7.94 KB
author spgraph-docs-team
title Get a SharePoint Site
ms.localizationpriority high
ms.subservice sharepoint
description Retrieve properties and relationships for a site resource.
doc_type apiPageType
ms.date 04/04/2024

Get a site resource

Namespace: microsoft.graph

Retrieve properties and relationships for a site resource. A site resource represents a team site in SharePoint.

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]

Note

When a user from one geo location attempts to access a site located in another geo, the request may fail unless the calling user has at least "Limited access" permission to the root site collection of the target geo. Make sure the access is granted to avoid authorization issues.

HTTP request

Get the tenant's root site

To access the root SharePoint site within a tenant:

GET /sites/root
GET /sites/contoso.sharepoint.com

Access a site by server-relative URL

If you have the server-relative URL for a site resource, you can construct a request as follows:

GET /sites/{hostname}:/{server-relative-path}

Access a group team site

To access the team site for a group:

GET /groups/{group-id}/sites/root

Request headers

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

Examples

Example 1: Get a site using the site ID

Request

The following example shows a request that gets a site by its site ID. A site ID is the value of the id property of its site resource. For more information on the format of the site ID, see site.

GET https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE

[!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

{
  "id": "contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE",
  "isPersonalSite": false,
  "displayName": "OneDrive Team Site",
  "name": "1drvteam",
  "createdDateTime": "2017-05-09T20:56:00Z",
  "lastModifiedDateTime": "2017-05-09T20:56:01Z",
  "webUrl": "https://contoso.sharepoint.com/teams/1drvteam"
}

Example 2: Get a site by server relative URL

Request

The following example shows a request that gets a site by its hostname and server relative path.

GET https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/teams/1drvteam

Response

The following example shows the response.

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

{
  "id": "contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE",
  "displayName": "OneDrive Team Site",
  "name": "1drvteam",
  "createdDateTime": "2017-05-09T20:56:00Z",
  "lastModifiedDateTime": "2017-05-09T20:56:01Z",
  "webUrl": "https://contoso.sharepoint.com/teams/1drvteam"
}

Example 3: Get the site of a group

Request

The following example shows a request that gets a group's site by the id property of a group.

GET https://graph.microsoft.com/v1.0/groups/2C712604-1370-44E7-A1F5-426573FDA80A/sites/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

{
  "id": "contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE",
  "displayName": "OneDrive Team Site",
  "name": "1drvteam",
  "createdDateTime": "2017-05-09T20:56:00Z",
  "lastModifiedDateTime": "2017-05-09T20:56:01Z",
  "webUrl": "https://contoso.sharepoint.com/teams/1drvteam"
}