I am trying to invite guest user in my Office 365 tenant using Azure AD B2B api and the intent is to set hireDate property of the guest user as soon as invitation is sent. For me its not necessary that guest should redeem the invitation. The problem is, code fails (with error message: Unable to check user existence in AD) when I am trying to patch user to update hireDate property irrespective of guest redeem the invitation or not. The problem does not occur if i wait for a minute or so after sending the invitation and then try to patch the user. How can I set this property without waiting?
To resolve this, i already tried implementing retry logic but this is not reliable.
var token = extranetHelper.GetAuthToken(); //Custom class to get token
var guestEmail = "[email protected]";
var siteURL = "https://tenant.sharepoint.com/sites/abc";
var displayName = "";
Invitation guestInvitation =
GraphUtility.InviteGuestUser(token.AccessToken, guestEmail, siteURL, "", displayName);
var guestUserId = guestInvitation.InvitedUser.Id;
var graphUrl = "https://graph.microsoft.com/beta/users/" + guestUserId;
var body = "{\"hireDate\" : \"" + DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ") + "\"}";
var response = GraphHttpClient.MakePatchRequestForString(graphUrl, JsonConvert.DeserializeObject(body), "application/json", token.AccessToken);
hireDate property should be set for the newly created guest user in Azure AD.