Forked from vman/Set.Single.UserProfileProperty.js
Created
December 12, 2017 09:42
-
-
Save maxali/3e8c39129aaac21468f07c16141b9a61 to your computer and use it in GitHub Desktop.
SharePoint Online: Set Single Value User Profile property with REST API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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|[email protected]", | |
'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