M365:Resolving exception “{ “error”: { “code”: “Forbidden”, “message”: “Failed to retrieve appliable Sku categories for the user”, “innerError”: { “request-id”: “e54c75bb-5268-4eaf-9d42-fa908255325c”, “date”: “2020-05-28T08:43:26″ } } } ” while creating M365 Group using CSOM

Hi All,

LIFE IS BEAUTIFUL 🙂 I hope we all are safe:) STAY SAFE, STAY HEALTHY 🙂 STAY HOME 🙂

Today new issue 🙂 and solution 🙂

Background / Use Case: For one of our customer we are doing team provisioning. So we have PowerApp as a UI for team creation, we are submitting the request to SharePoint list called “Team Order” list.

We have written console job which have following high level algorithm queries to the “Team Order” list get the details and create

  • Queries to the “Team Order” list and get the details required for creating M365 group
  • Create M365 Group
  • Create Team, associate with the created M365 group

Everything is working fine. But some new users are added to tenant and when one of those user is specified as Group owner it failed with given exception.

Issue / Exception:

{
“error”: {
“code”: “Forbidden”,
“message”: “Failed to retrieve appliable Sku categories for the user”,
“innerError”: {
“request-id”: “e54c75bb-5268-4eaf-9d42-fa908255325c”,
“date”: “2020-05-28T08:43:26”
}
}
}

StackTrace:

Response code: Forbidden
Message: Forbidden
at WorkspaceCreation.d__4.MoveNext()

— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at WorkspaceCreation.Start()

Solution: Just to share we are using Graph APIs to add the Group owners, following is the sample code:

JObject groupCreationInformation = new JObject();
JArray groupOwners = new JArray();

var ownerId1 = user1ID;
var ownerId2 = user2ID;

 if (ownerId1 != null){
       groupOwners.Add($"https://graph.microsoft.com/v1.0/users/{ownerId1}");
     }
 if (ownerId2 != null){
       groupOwners.Add($"https://graph.microsoft.com/v1.0/users/{ownerId2}");
    }

groupCreationInformation["owners@odata.bind"] = groupOwners;

var _content = groupCreationInformation.ToString();

var content = new StringContent(_content, Encoding.UTF8, "application/json");

var result = await hc.PostAsync("https://graph.microsoft.com/v1.0/groups", content);

var resultStr = await result.Content.ReadAsStringAsync();

Since – “code”: “Forbidden”, we thought its permission issue, but we are running code on behalf of Azure App. So it shouldn’t be an issue.

After bit googling we observed that user which we are assigning as a owner dont have license assigned.

So conclusion is if we assigned M365 group owner who dont have license assigned we will get such error.

Thanks for reading 🙂 If its worth at least reading once, kindly please like and share. SHARING IS CARING 🙂

Enjoy the beautiful life 🙂 Have a FUN 🙂 HAVE A SAFE LIFE 🙂 TAKE CARE 🙂

This site uses Akismet to reduce spam. Learn how your comment data is processed.