Wednesday, December 17, 2014

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

No comments:

Post a Comment