Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The SharePoint API in Microsoft Graph supports the following core scenarios:
The SharePoint API exposes three major resource types:
The following is an example of a listItem resource.
{
"fields": {
"Title": "Access card",
"Employee": "Ryan Gregg",
"EmployeeId": "10",
"CardSerial": "01235492",
"Alias": "RGregg",
"ID": 1,
"ContentType": "Item",
"Modified": "2016-09-19T23:15:25-07:00",
"Created": "2016-09-19T23:15:25-07:00"
},
"createdBy": {
"user": {
"id": "b757fdcb-0271-4807-b243-504139e4ba04",
"displayName": "Ryan Gregg"
}
},
"createdDateTime": "2016-09-20T06:15:25Z",
"eTag": "48e941c3-9515-4c48-9760-c07c90c79d48,1",
"id": "4",
"lastModifiedBy": {
"user": {
"id": "b757fdcb-0271-4807-b243-504139e4ba04",
"displayName": "Ryan Gregg"
}
},
"lastModifiedDateTime": "2016-09-20T06:15:25Z",
}
Resources expose data in three different ways:
You can expand references in your URL with the expand query parameter; for example, ?expand=fields
.
You can request specific properties and facets with the select query parameter; for example, ?select=id,name
.
By default, most properties and facets are returned while all references are hidden.
For efficiency, we recommend that you specify select and expand to only return the data you care about.
The following examples are relative to https://graph.microsoft.com/beta
.
Path | Description |
---|---|
/sites/root | Organization's default site. |
/sites/{site-id} | Access a specific site by its ID. |
/sites/{site-id}/drive | Access the default drive (document library) for the given site. |
/sites/{site-id}/drives | Enumerate the drives (document libraries) under the site. |
/sites/{site-id}/sites | Enumerate the sub-sites under the site. |
/sites/{site-id}/lists | Enumerate the lists under the site. |
/sites/{site-id}/lists/{list-id}/items | Enumerate the listItems under the list. |
/groups/{group-id}/sites/root | Access a group's team site. |
/admin/sharepoint/settings | Access the organization's admin level settings. |
Sites can also be addressed by path by using the SharePoint hostname, followed by a colon and the relative path to the site. You can optionally transition back to addressing the resource model by putting another colon at the end.
Path | Description |
---|---|
/sites/contoso.sharepoint.com:/teams/hr | The site associated with https://contoso.sharepoint.com/teams/hr |
/sites/contoso.sharepoint.com:/teams/hr:/drive | Access the default drive for this site. |
The Microsoft Graph SharePoint API has a few key differences with the CSOM APIs.
The site resource maps to SPWeb
.
The root site (SPWeb
) in a site collection has a siteCollection facet, which contains information about the SPSite
.
Because IDs for sites are only unique within their site collection, addressing a site by ID requires providing both the site collection identifier and the site identifier.
GET https://graph.microsoft.com/beta/sites/{hostname},{spsite-id},{spweb-id}/
A URL constructed with only the hostname points to the root site (SPWeb
) in the default site collection.
GET https://graph.microsoft.com/beta/sites/{hostname}
A URL constructed with only the hostname and siteCollection (SPSite
) ID points to the root site (SPWeb
) in the given site collection.
GET https://graph.microsoft.com/beta/sites/{hostname},{spsite-id}
A URL constructed with only the siteCollection (SPSite
) ID points to the root site (SPWeb
) in the given site collection.
GET https://graph.microsoft.com/beta/sites/{spsite-id}
The following examples help developers familiar with SharePoint REST v1 API URL patterns adapt their use cases to similar Microsoft Graph API URL patterns.
Access the site associated with the specified SPWeb
URL.
GET https://graph.microsoft.com/beta/sites/{hostname}:/{site-server-relative-url}
The following example returns information about the site associated with the SPWeb
URL https://contoso.sharepoint.com/teams/hr/benefits
. Note that benefits
is an SPWeb
within the site collection (SPSite
) at https://contoso.sharepoint.com/teams/hr
.
GET https://graph.microsoft.com/beta/sites/contoso.sharepoint.com:/teams/hr/benefits
Access the list item associated with the following components.
Component | Description |
---|---|
{hostname} | The hostname of the site. |
{site-server-relative-url} | The server-relative URL of the site (SPWeb ). |
{list-id} | The GUID ID of the list (SPList ) in the site. |
{item-id} | The GUID or integer ID of the list item (SPListItem ) in the list. |
The following example shows a request that contains the previous components.
GET https://graph.microsoft.com/beta/sites/{hostname}:/{site-server-relative-url}:/lists/{list-id}/items/{item-id}
The following example returns information about the SPListItem
with integer ID 42
that belongs to the list with GUID ID 5771e865-4e91-48b8-a0de-35a25d4e52fe
. This list belongs to the site associated with the SPWeb
URL https://contoso.sharepoint.com/teams/hr/benefits
.
GET https://graph.microsoft.com/beta/sites/contoso.sharepoint.com:/teams/hr/benefits:/lists/5771e865-4e91-48b8-a0de-35a25d4e52fe/items/42
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now