url: appweburl + "_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='Manager')?@v='" + seluser + "'"
,
For my SP 2013 app I need to get a users manager and I'm using the following code to achieve this:
function getusersManager(selUser) {
//clear any errors
var errModalArea = document.getElementById("modalAnnouncements");
// Remove all nodes from the errAllEvents <DIV> so we have a clean space to write to
while (errModalArea.hasChildNodes()) {
errModalArea.removeChild(errModalArea.lastChild);
}
var seluser = selUser;
var executor = new SP.RequestExecutor(appweburl.toLowerCase());
executor.executeAsync({
url: appweburl + "_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='Manager')?@v='" + seluser + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: successGetUserManager,
error: errorGetEmployee
});
}
function successGetUserManager(data) {
var jsonObject = JSON.parse(data.body);
var announcementsHTML = "";
document.getElementById("renderAnnouncements").innerHTML = "<b> Hello " + jsonObject.d.Manager;
//$('#txtManger').val(jsonObject.d.Manager);
}
However this keeps returning a "undefined". Putting the call directly into the browser using
https://xxx.sharepoint.com/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='Manager')?@v=%27i:0%23.f|membership|[email protected]%27
Gives me back the correct data but I'm unsure how to get that value...I see no key etc?
<d:GetUserProfilePropertyFor xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">i:0#.f|membership|[email protected]</d:GetUserProfilePropertyFor>