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 πŸ™‚

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

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

%d bloggers like this: