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\":\"\"}]";


I get no errors but the control is added with no user.

Anyone knows how to do this?

  • If I try to set peopleComp["persons"] instead of propertiesJson the site presents a "load people" symbol when opening but never gets finnished Dec 18, 2018 at 11:47

1 Answer 1

var peopleComp = page.InstantiateDefaultWebPart(DefaultClientSideWebParts.People);

if (peopleComp != null)
      peopleComp.Title = "people";
      peopleComp.PropertiesJson = "{'layout':1, 'persons':[{'id':'i:0#.f|membership|USERMAIL'}],'title':''}";


page.Save(your site url)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.