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

How to launch a document by clicking a link to the file?

Word: <a href='ms-word:ofe|u|path/to/web/word/document.docx'>Link to document</a> Excel: <a href='ms-excel:o...