Access Personal SharePoint Site With Graph API

Access SharePoint site

To access a SharePoint site you need to know either the site id or the server-relative URL for a site.

GET /v1.0/sites/{site_id}
GET /v1.0/sites/{hostname}:/{server_relative_path}

Personal site

The personal site of any user within the tenant has the following URL:

https://tenant-my.sharepoint.com/personal/name_email_domain

Examples:

User Personal SharePoint site URL
johndoe@contoso.com https://contoso-my.sharepoint.com/personal/johndoe_contoso_com
AdeleV@contoso.onmicrosoft.com https://contoso-my.sharepoint.com/personal/adelev_contoso_onmicrosoft.com
Miriam.Graham@contoso.onmicrosoft.com https://contoso-my.sharepoint.com/personal/miriam_graham_contoso_onmicrosoft.com

Get URL of personal site

The URL for the user's site is stored in the property mySite of the user resource.

You can't retrieve the URL for all users by one call

GET /v1.0/users?$select=id,mySite

You have to send a request for each user and specify mySite in $select query parameter that you want to read this property.

GET /v1.0/users/{user_id}?$select=id,mySite

Access personal site with server relative URL

With the knowledge of personal site's URL, you can create the request:

GET /v1.0/sites/contoso-my.sharepoint.com:/personal/johndoe_contoso_com

Find id of the personal site

Do you want to search for personal site? If yes, use /search/query endpoint

POST /v1.0/search/query

{
    "requests": [
        {
            "entityTypes": [
                "site"
            ],
            "query": {
                "queryString": "\"https://contoso-my.sharepoint.com/personal/johndoe_contoso_com\""
            }
        }
    ]
}

Wrap the URL of the personal site into double quotes.

0
Buy Me a Coffee at ko-fi.com
An error has occurred. This application may no longer respond until reloaded. Reload x