I am writing a C# application where I have to update a user profile property. I am using the following code:
using (var clientContext = new ClientContext(serverUrl))
{
var peopleManager = new Microsoft.SharePoint.Client.UserProfiles.PeopleManager(clientContext);
var personProperties = peopleManager.GetPropertiesFor(targetUser);
clientContext.Load(personProperties, p => p.AccountName);
clientContext.ExecuteQuery();
peopleManager.SetSingleValueProfileProperty(personProperties.AccountName, property, newValue);
// the following line throws exception 'Method "SetSingleValueProfileProperty" does not exist.'
clientContext.ExecuteQuery();
}
I receive a
'Method "SetSingleValueProfileProperty" does not exist'
exception, when executing clientContext.ExecuteQuery()
the second time.
If I do not use clientContet.ExecuteQuery()
, the change of the previous line is not done.
What am I doing wrong?