I'm trying to programatically(c#) add a user to a sharepoint People web part on a modern page but with no success.
I try to set the "persons"-property the same way it looks after adding a person manually.
var peopleComp = page.InstantiateDefaultWebPart(DefaultClientSideWebParts.People);
dynamic json = JObject.Parse(peopleComp.PropertiesJson.ToString());
json["persons"] = "[{\"id\":\"i:0#.f|membership|[email protected]\",\"upn\":\"[email protected]\",\"role\":\"IT\",\"department\":\"IT\",\"phone\":\"\",\"sip\":\"\"}]";
page.AddControl(peopleComp);
page.Save(model.Url);
I get no errors but the control is added with no user.
Anyone knows how to do this?