Microsoft Graph APi to create List item with PersonAndGroup

Regular Visitor

I'm trying to create a sharepoint list view item with one column of type personandgroup using graph API.  The person or group is not part of sharepoint but its available in Microsoft 365. But Microsoft graph API creates item only when i pass PersonAndGroup value as sharepoint id if i try to pass claim it does not work. As users and groups have not logged in or connected "user Information List" does not have Users I'm trying to populate and not able to create a new List item. 

 

Following is working without any issue as long as user id exists in the "user Information List"

 

var listItem = new Microsoft.Graph.ListItem
{
Fields = new FieldValueSet
{
AdditionalData = new Dictionary<string, object>()
{
{"UsernameLookupId", "14"}, //PersonAndGroup where I'm passing sharepoint user Id
{"groupname", "Avengers"},
{"Title" , "Captain America"}, //Permission
{"Role", "User" },
{"GroupId" , ""},
{"UserId" ,""}
}
}
};

 

Is there anyway to populate lookup (personandgroup) value without sharepoint userid something like below

 

 

var listItem = new Microsoft.Graph.ListItem
{
Fields = new FieldValueSet
{
AdditionalData = new Dictionary<string, object>()
{
{"Username", { "user": {"id": "{UserId}"}  }
}

}
};

 

3 Replies

@Chitrarasan I really need to know this too. I am trying to migrate an old list from Sharepoint 2013 to a new list that has PersonOrGroup fields.

For some reason, this is not working for me. I am passing this JSON and using the Graph SDK (which is using the v1.0 endpoint)
{
"fields":{
"Title":"Test",
"Description":"TestDesc",
"Person":"12"
},
"@odata.type":"microsoft.graph.listItem"
}

The person is not filled in the Person column. Do you know what I might be doing wrong?
Thanks!
Omg super tricky. I found it from your Bold font of username. I figured that I need to append "LookupId" to my column name. Why? Go figure.
Thanks!