REST programming in SharePoint is straightforward. Microsoft has shared the latest REST way of programming for SharePoint through Graph API. Microsoft Graph APIs are a rich source of APIs for accessing various resources of Office365 like SharePoint, Users, Onedrive. We will focus on SharePoint here.

Why use Graph API in SharePoint?

  • Letting developers develop from other platforms like iOS and Android
  • Like AI coding. Intelligent access from different sources
  • RESTful. Latest REST.
  • Any programming language

Precautions:

Use in production is not supported due to drastic changes. Sometimes, the results were not working in v1, and I had to change to the beta version.

However, I started seeing real SharePoint projects using Graph API while freelancing and predicting that this will be a good and easy way to program in future soon by all.

We will look at how to construct a REST Url for Graph for SharePoint site.

https://graph.microsoft.com/{version}/{Resource}/{ODATA}

  • https://graph.Microsoft.com
  • /version
    • v1
    • beta
  • Resource
    • Site
    • List
  • ODATA
    • Select
    • Filter
    • expand

SharePoint Site Queries

Login to Graph Explorer from the link https://developer.microsoft.com/en-us/graph/graph-explorer 

Type the query and click Run Query.

Below are some sample site Queries

  • Search for sites
    • https://graph.microsoft.com/v1.0/sites?search=*
  • Get Site ID. The Site ID contains hostname,SiteCollection ID and the Web ID
    • xxx.sharepoint.com,bd041326-835c-4013-ae95-b57b4fcd0484,f6d916a3-27e1-449f-addf-82e750661823
  • Read Site By ID
    • https://graph.microsoft.com/beta/sites/xxx.sharepoint.com,bd041326-835c-4013-ae95-b57b4fcd0484,f6d916a3-27e1-449f-addf-82e750661823
  • Read Site By Path
    • https://graph.microsoft.com/beta/sites/xxx.sharepoint.com:/sites/dev
  • Read Site Pages
    • https://graph.microsoft.com/beta/sites/xxx.sharepoint.com,bd041326-835c-4013-ae95-b57b4fcd0484,f6d916a3-27e1-449f-addf-82e750661823/pages

Comparison with SharePoint Rest Url

While working on old SharePoint REST, you would begin the SharePoint rest URL with the site link.

Example : https://xxx.sharepoint.com/_api/web/title

Graph SharePoint
Read Sites Only Create Sites also
Root Url : https://graph.microsoft.com/beta Root Url : https://xxx.sharepoint.com/_api/web/title
Select Items ?select=Title Select Items ?select=Title
Expanding ?expand=Author Expanding ?expand=Author

Summary

You learnt how to construct SharePoint Sites URL in Microsoft Graph:

  • Read Sites by ID
  • Read Sites by Path
  • Read the Pages in a Site

 

(8947)

Views: 8.95K  | Categories: Development, Graph & Delve, SharePoint, Uncategorized
About The Author
- I love exploring SharePoint and talking about SharePoint. Few of my contributions can be viewed here https://www.youtube.com/channel/UCGqSWCnFPZ4GuPEwjtCYx1A/videos?sort=dd&view=0&shelf_id=0