SharePoint 2013: Get UserProfile Properties with REST API
1) Get all properties of current user:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties2) Get single property of current user:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties/PictureUrlOR
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=PictureUrl
3) Get Multiple Properties for the current user:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=PictureUrl,AccountName4) Get all properties of Specific User:
For Office 365/SharePoint Online:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='user name'
For SharePoint 2013 On-Premise:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='domain\username'
5) Get Specific UserProfile Property of Specific User:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='LastName')?@v='user name'
For SharePoint 2013 On-Premise:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='LastName')?@v='domain\username'
var theData = {
"propertiesForUser": {
"__metadata": { "type": "SP.UserProfiles.UserProfilePropertiesForUser" },
"accountName": "user name",
"propertyNames": ["PreferredName", "Department"]
}
};
var requestHeaders = {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
};
jQuery.ajax({
url:_spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertiesFor",
type:"POST",
data: JSON.stringify(theData),
contentType : "application/json;odata=verbose",
headers: requestHeaders,
success:function(data){
console.log(data);
},
error:function(jqxr,errorCode,errorThrown){
console.log(jqxr.responseText);
}
});
more info: http://www.vrdmn.com/2013/07/sharepoint-2013-get-userprofile.html
Comments
Post a Comment