Microsoft Graph APi to create List item with PersonAndGroup

%3CLINGO-SUB%20id%3D%22lingo-sub-2278704%22%20slang%3D%22en-US%22%3EMicrosoft%20Graph%20APi%20to%20create%20List%20item%20with%20PersonAndGroup%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2278704%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20create%20a%20sharepoint%20list%20view%20item%20with%20one%20column%20of%20type%20personandgroup%20using%20graph%20API.%26nbsp%3B%20The%20person%20or%20group%20is%20not%20part%20of%20sharepoint%20but%20its%20available%20in%20Microsoft%20365.%20But%20Microsoft%20graph%20API%20creates%20item%20only%20when%20i%20pass%20PersonAndGroup%20value%20as%20sharepoint%20id%20if%20i%20try%20to%20pass%20claim%20it%20does%20not%20work.%20As%20users%20and%20groups%20have%20not%20logged%20in%20or%20connected%20%22user%20Information%20List%22%20does%20not%20have%20Users%20I'm%20trying%20to%20populate%20and%20not%20able%20to%20create%20a%20new%20List%20item.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFollowing%20is%20working%20without%20any%20issue%20as%20long%20as%20user%20id%20exists%20in%20the%20%22user%20Information%20List%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Evar%20listItem%20%3D%20new%20Microsoft.Graph.ListItem%3CBR%20%2F%3E%7B%3CBR%20%2F%3EFields%20%3D%20new%20FieldValueSet%3CBR%20%2F%3E%7B%3CBR%20%2F%3EAdditionalData%20%3D%20new%20Dictionary%3CSTRING%3E()%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%7B%22%3CSTRONG%3EUsername%3C%2FSTRONG%3ELookupId%22%2C%20%2214%22%7D%2C%20%2F%2FPersonAndGroup%20where%20I'm%20passing%20sharepoint%20user%20Id%3CBR%20%2F%3E%7B%22groupname%22%2C%20%22Avengers%22%7D%2C%3CBR%20%2F%3E%7B%22Title%22%20%2C%20%22Captain%20America%22%7D%2C%20%2F%2FPermission%3CBR%20%2F%3E%7B%22Role%22%2C%20%22User%22%20%7D%2C%3CBR%20%2F%3E%7B%22GroupId%22%20%2C%20%22%22%7D%2C%3CBR%20%2F%3E%7B%22UserId%22%20%2C%22%22%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3B%3C%2FSTRING%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20anyway%20to%20populate%20lookup%20(personandgroup)%20value%20without%20sharepoint%20userid%20something%20like%20below%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Evar%20listItem%20%3D%20new%20Microsoft.Graph.ListItem%3CBR%20%2F%3E%7B%3CBR%20%2F%3EFields%20%3D%20new%20FieldValueSet%3CBR%20%2F%3E%7B%3CBR%20%2F%3EAdditionalData%20%3D%20new%20Dictionary%3CSTRING%3E()%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%7B%22%3CSTRONG%3EUsername%3C%2FSTRONG%3E%22%2C%20%7B%26nbsp%3B%22user%22%3A%20%7B%22id%22%3A%20%22%7BUserId%7D%22%7D%26nbsp%3B%20%7D%3CBR%20%2F%3E%7D%3C%2FSTRING%3E%3C%2FP%3E%3CP%3E%7D%3CBR%20%2F%3E%7D%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2278704%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20Graph%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
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}"}  }
}

}
};

 

0 Replies