Training Session: Graph API – OneDrive vs SharePoint


Microsoft has invested heavily into their Graph API which connects with the Office 365 services. The approach of old, CSOM, not so much as of late. But that makes sense considering the services are cloud-hosted.

CSOM was perfect for solutions running on the application server, but [SharePoint Online] doesn’t allow this. Going forward, the Graph API is recommended approach…


Remembering that SPO and [OneDrive for Business] are now cloud-hosted, they live in an infrastructure managed by Microsoft. To leverage SPO and ODfB, organizations are now “tenants” of the Office 365 ecosystem.

E.g., if I worked for the Contoso company, then their tenant name would likely be Contoso. This tenant name is a part of the URL for SPO and ODfB sites…


If I needed to query the site ID of Contoso’s Portal site; created under the /sites/ managed path:

$url = "/sites/portal"
$api = "https://graph.microsoft.com/v1.0/"
$req = "$($api)/sites/contoso.sharepoint.com:$($url)/"

Though, if I needed to query the site ID my ODfB site; created under the /personal/ managed path:

$url = "/personal/charles_lakes_contoso_com"
$api = "https://graph.microsoft.com/v1.0/"
$req = "$($api)/sites/contoso-my.sharepoint.com:$($url)/"

The relative URL specifies the target site. Yet, the inclusion of “-my” points the API to ODfB.


Conclusion:
SPO sites and ODfB sites all live beneath the organization’s tenant. The Graph API uses the site’s relative path to determine the target site under a specific managed path.

“Leadership is found in the action to defeat that which would defeat you… You are made by the struggles you choose.”

Cordy Tindell Vivian

#blacklivesmatter

Leave a comment