Reputation: 304
I'm trying to programmatically retrieve informations about the SharePoint site after creating an office group using Microsoft Graph API.
Each office group has one SharePoint site assigned to it, but I'm not able to determine the url of the site except for manually browsing to the site and copying it.
This is not a feasible solution as I have to create hundreds of Office groups and subscripe to webhooks on the corresponding SharePoint site.
Also this link is important to me as I don't want to open up the site manually each time before it's created.
Upvotes: 1
Views: 687
Reputation: 56
You can do this by making a GET-Request with your group id against
https://graph.microsoft.com/v1.0/groups/<your group id>/drive/root/webUrl.
This will give you information about the documents on the SharePoint site, including the URL. you will get something like this:
cache-control: private
content-type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
request-id: <some id>
client-request-id: <some id>
Status Code: 200
{
"@odata.context": https://graph.microsoft.com/v1.0/$metadata#groups(<your group id>)/drive/root/webUrl",
"value": "https://<your tennant>.sharepoint.com/sites/<generated SharePoint name>/Shared%20Documents"
}
If you do this with a newly created group the site won't exist yet, so you will get a resource not found
response. But it will come up with the expected answer when you try again.
Upvotes: 1