SharePoint site for Office 365 group not created when group is created programmatically via Graph

New Contributor

I have created Office 365 Group programmatically via C# and Graph. The group shows up as expected in Outlook but when I try to enter the site https://<tenant><mailNickName> I just got an "empty" page with:

HTTP/1.1 200 OK
Server: Microsoft-IIS/8.5
Date: Wed, 21 Jun 2017 07:56:01 GMT
Connection: close

When I try to access the site via Csom I get to the root https://<tenant> and not the created Group Site.

To generate the Group Site I have to go to URL:


where id is the group ID. After 5-10 seconds it's generated. When I try to fire of the URL from my app, I get Unauthorized even if the app have full authorization/all permisions for SharePoint in Azure Ad.


Are there any way I can generate the group site programmatically?


Addition: I have tried to authenticate the http request as myself in the c# app. It succed for https://<tenant> but fails with the same authentification with Unathorized for https://<tenant>

5 Replies

I finally got it working by using SharePoint Online HTTP handler (SPHttpClientHandler) from this page to post the activation url. It uses a logged on users context and not Azure App context.


I still wonder if it's possible to create the Office 365 SharePoint site using Azure App authorization

How are you creating the group? Have you tried this code from the PnP team:

In theory, it says: "Modern" team sites are created programmatically by creating an Office 365 group using Microsoft Graph. When you create an Office 365 group a "modern" team site is automatically provisioned for the group. The "modern" team site URI will be based upon the mailNickname parameter of the Office 365 group and has the following default structure"

Yes I have tried it but had problems with the athentification token which always gave me "Unauthorized" (or something) even if the app had full permisions in Azure AD. After several tries I found an other way which works. 


My current coding works fine with only Read/Write Group permission, but the site is not created. For this I use a user context to activate by doing a get-request.

I had the same issue with app only authentication and ended up with the same solution as you - make a http request authenticating as a user. The PnP library internally makes a request to the Graph API root drive to try and trigger the site to be provisioned but this too fails with app-only credentials.


Would love to see this change as it's really messy to do http requests as a user in our provisioning engine when we would rather just use app-only authentication.

best response confirmed by Per Ola Sneve (New Contributor)

This is now working as expected. You can create O365 groups with SharePoint sites via Graph API using app-only credentials. I am using the PnP UnifiedGroups utility and this works pretty well with a few exceptions though now and than.