I'm facing an issue with adding a user to a PersonOrGroup field in a SharePoint list using only the MS Graph API. The problem arises when the user has never interacted with the site, and thus, doesn't exist in the site's internal 'users' list. Without this, I can't obtain the necessary user Lookup ID for the field.
In the SharePoint REST API, there is a function called 'ensureuser' that serves to retrieve a user object from the site's user list. If the user doesn't already exist in the list, this function adds them and then returns their Lookup ID, which can be used to include the user. However, as far as I know, there isn't an equivalent functionality available in the Graph API.
POST https://{site_url}/_api/web/ensureUser
Content-Type: application/json
{
"loginName":"{upnOrEmail}"
}
Info from Sharepoint API:
The users I want to add are part of the same tenant, and I can retrieve all their information using the Graph API with this call: graph.microsoft/v1.0/users/{{emailAddress}}.
Is there a solution or alternative method to add a user from the same tenant to a site's 'users' list using the Graph API, similar to the ensureuser feature in the SharePoint API?
Thanks in advance for any insights or suggestions!
Seeking the proper method in .NET C# code to add an existing user to the 'users' list of a SharePoint site using the Microsoft Graph API.