SharePoint REST query SP.UserProfiles.PeopleManager
11,447
How to retrieve Manager property via SharePoint User Profiles REST API
var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
var accountName = 'Domain\\Login';
$.ajax({
url: siteUrl + "/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='" + encodeURIComponent(accountName) + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
if(data.d.DirectReports.results.length > 0)
{
console.log('User has managers');
}
},
error: function (data) {
console.log(JSON.stringify(data));
}
});
Author by
stockDevelopers
Updated on June 14, 2022Comments
-
stockDevelopers almost 2 years
Is it possible to get data using REST query like below:
http://moss.moss/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='user_domain\user'&$filter=DirectReports
And call by JavaScript.
I would like to create script which will check if user is a manager (has DirectReports) and next display JavaScript alert.
Thanks in advance!
-
stockDevelopers about 10 yearsHi, thanks! How can I replace 'Domain\\Login' to current user?
-
Vadim Gremyachev about 10 yearsThe following REST request /_api/Web/CurrentUser/LoginName returns the LoginName for the current user
-
Ali almost 10 yearsI am trying to get "QuickLinks" from user profile, this request returns almost everything but "QuickLinks" is empty, I have tried CSOM to fetch user info but that also gives me empty string, getting quick links is not supported or I need to have a look somewhere else?
-
Nick Cox over 9 years@stockDevs: If you want the properties for the current user you can replace /_api/SP.UserProfiles.PeopleManager/GetPropertiesFor[...] with /_api/SP.UserProfiles.PeopleManager/GetMyProperties