Azure AD, unable to set AdditionalData against Invitation

Viewed 176

I am using the GraphServiceClient to create invitation to add Guest in Azure Ad and I need to add AdditionalData in the invitation.

var invitation = new Microsoft.Graph.Invitation
{
     InvitedUserDisplayName = "John Doe",
     InvitedUserEmailAddress = "john.doe@test.com",
     InviteRedirectUrl = "https://test.com",
     SendInvitationMessage = false,
     AdditionalData = new Dictionary<string, object>
     {
      {"JobTitle", "Doctor"},
      {"UsageLocation", "FR"}
     }
};

await graphClient.Invitations
      .Request()
      .AddAsync(invitation);

John Doe is created as Guest in Azure Ad, but JobTitle and UsageLocation are null. Is it possible to add AdditionalData on invitation or only on user ?

Regards

1 Answers

Seems you are trying to invite guest user along with AdditionalData using Microsoft Graph API SDK.

You could try this way:

            InvitedUserMessageInfo info = new InvitedUserMessageInfo();
            object obj = new object();
            obj = "Testing Another Additional Data";

            var dict = new Dictionary<string, object>();
            dict.Add("Data1", obj);
            dict.Add("Data2", obj);
            info.AdditionalData = dict;
            

     

            var invitation = new Invitation
            {
                InvitedUserEmailAddress = "testemail@outlook.com",
                InviteRedirectUrl = "https://yourapplicationurl.com",
                InvitedUserMessageInfo = info
            };

                 await _graphServiceClient.Invitations
                .Request()
                .AddAsync(invitation);

Note: Make sure you have required permission on your Tenant as specified on Microsoft official document

Hope it will help. Let me know if you have any further concern.

Related