Insights Using the Graph API with SharePoint

Using the Graph API with SharePoint

Using the Graph API with SharePoint

The Graph API provides access to SharePoint items such as site collections, lists, document libraries and files.  See the article  for a walkthrough on retrieval of an access token needed to use the Graph API.

Site Collections

Once authenticated to the Graph API it’s possible to retrieve the site collections for the logged in account using the url*
The results will contain an array of metadata for each site collection.

The key field is id, this id is in the form of <hostname>, <site collection GUID>,<site GUID> and will allow you to address that site collection directly.

If we then substitute that id string into the url<id>
we can get the metadata for that site. For the remaining examples we will use <id> as a placeholder for the site collection id from the previous query.

Sites<id> returns the metadata for the root site of the site collection<id>/sites returns the list of subsites for a given site collection

List Elements

Lists<id>/lists retrieves the lists for the site. The List Name element in the following urls is the display name field, not the name field.
List metadata<id>/lists/<ListName> retrieves the metadata for that list
List Items<id>/lists/<ListName>/items retrieves the items from the list.
List Item<id>/lists/<ListName>/items/<ItemId>. The item ID is from the List Item metadata and is a number.

Document Libraries

The Library Name is the Display Name of the Library.
The item ID is from the item metadata and looks like: 01ISO65YJFGX6MUL7F25D23LGBAY53O7YK, this id is unique to the document library and will span folders.

Library Root Folder<id>/lists/<LibraryName>/drive/root to get the root folder of the document library.
Library Items<id>/lists/<LibraryName>/drive/root/children to get the root folder document metadata items.
Library Item metadata<id>/lists/<LibraryName>/drive/items/<ItemId> to get the individual item metadata
Library Item Contents<id>/lists/<LibraryName>/drive/items/<ItemId>/content
 to get the individual item bytes
Library Folders<id>/lists/<LibraryName>/drive/root/children/<FolderPath>/children to get the folder contents

Microsoft Graph Explorer

Use the Microsoft Graph Explorer to quickly browse the Graph API to discover the urls and properties available.