79109733

Date: 2024-10-21 11:07:16
Score: 1
Natty:
Report link

As user2250152 stated, you need to "create" the role first before you can get the directory role.

This fixed it for me:

            DirectoryRole globalReaderRole;

            if (result.Value.Count == 0)
            {
                globalReaderRole = await graphServiceClient.DirectoryRoles.PostAsync(new DirectoryRole
                {
                    RoleTemplateId = tmplRole.Id 

                });
            }
            else
            {
                globalReaderRole = result.Value.FirstOrDefault();
            }
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): user2250152
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: baswijdenesdotcom