Thursday, March 16, 2017

Microsoft Graph adds SharePoint endpoint for Groups in the beta branch

[Update] Use https://graph.microsoft.com/v1.0/groups//sites/root/weburl to get a web url as the SharePoint endpoint never made it to production.

I’m calling the Microsoft Graph with Office 365 groups these days and I stumbled upon a new SharePoint endpoint for Groups.

If you call:

https://graph.microsoft.com/beta/groups/821b0970-fae7-4640-bb22-5d091fd17a33/sharepoint/site

you will get the following information back, listing the site name and URL – a better approach compared to using the /drive/root/webUrl endpoint as you don’t have to strip anything.

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#groups('821b0970-fae7-4640-bb22-5d091fd17a33')/sharepoint/site/$entity",
    "createdDateTime": "2017-03-16T16:55:39.19Z",
    "description": "",
    "id": "42d1e3d3-a645-4388-a217-4d88380802df,de4b0a91-5caa-4732-a530-67cfb2b0c42d",
    "lastModifiedDateTime": "2017-03-16T11:00:08Z",
    "name": "project-govtest",
    "webUrl": "https://tenant.sharepoint.com/teams/project-govtest",
    "root": {},
    "siteCollection": {
        "hostname": "tenant.sharepoint.com"
    },
    "siteCollectionId": "42d1e3d3-a645-4388-a217-4d88380802df",
    "siteId": "de4b0a91-5caa-4732-a530-67cfb2b0c42d"
}

If all you want is the url, use /sharepoint/site/webUrl.