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);
   }
}); 

Comments

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell