Marios Nikolaou
Marios Nikolaou

Reputation: 1336

Microsoft Graph SDK get site url after group is created

I try to retrieve the site url when a microsoft-365 group is created in sharepoint using graph sdk. I read from docs that in order to access a group team site I should use GET /groups/{group-id}/sites/root BUT I don't know how to do it.

Also I have tried code below but throws exception that resource was not found.

var site = await graphClient.Sites[$"/groups/{group.Id}/sites/root"]
    .Request()
    .GetAsync();

I would like to know if I can modify the code above and use the group id to retrieve the active site url. Thanks in advance.

Upvotes: 1

Views: 991

Answers (1)

Amos
Amos

Reputation: 2091

Try this:

 graphClient.Groups["0745be26-2d8a-4f8d-be2d-37356a4794a3"].Sites["root"].Request().GetAsync().Result;

My test result: enter image description here

Upvotes: 1

Related Questions