Get current logged in username using REST API
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=DisplayName",
type: "GET",
headers: {"accept": "application/json;odata=verbose"},
success: function (data) {
userName=data.d.DisplayName;
},
error: function (xhr) {
alert(xhr.status + ': ' + xhr.statusText);
}
});
url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=DisplayName",
type: "GET",
headers: {"accept": "application/json;odata=verbose"},
success: function (data) {
userName=data.d.DisplayName;
},
error: function (xhr) {
alert(xhr.status + ': ' + xhr.statusText);
}
});
Comments
Post a Comment