Skip to content

Instantly share code, notes, and snippets.

@vman
Last active July 7, 2023 14:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vman/1353e0151966113340f6bc297e34c43f to your computer and use it in GitHub Desktop.
Save vman/1353e0151966113340f6bc297e34c43f to your computer and use it in GitHub Desktop.
SharePoint Online: Set Single Value User Profile property with REST API
(function ($) {
'use strict';
var requestHeaders = {
'X-RequestDigest': $("#__REQUESTDIGEST").val(),
"accept": "application/json; odata=nometadata",
"content-type": "application/json;odata=nometadata"
};
var userData = {
'accountName': "i:0#.f|membership|user@yourtenant.onmicrosoft.com",
'propertyName': 'AboutMe', //can also be used to set custom single value profile properties
'propertyValue': 'Value set from REST API!'
}
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/SetSingleValueProfileProperty",
type: "POST",
headers: requestHeaders,
data: JSON.stringify(userData),
success: function (data) {
console.log(data)
},
error: function (jqxr, errorCode, errorThrown) {
console.log(jqxr.responseText);
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment