Search This Blog

Friday, November 10, 2017

Get Logged User / Current user Details Using Rest Api


//Call  the function  Where You Want to use 

getUser(_spPageContextInfo.userId);
 
 // Fuction Body
function getUser(id){
var returnValue;
  jQuery.ajax({
   url: vUrl +"/_api/Web/GetUserById(" + id + ")",
   type: "GET",
   async:false,
   headers: { "Accept": "application/json;odata=verbose" },
   success: function(data) {
           var dataResults = data.d;
      //get login name 
      var loginName  = dataResults.LoginName.split('|')[1];
      var Email=dataResults.Email;
      returnValue=loginName+";"+Email;
     // returnValue=loginName;
   }
  
 });
return returnValue;
 
}

No comments:

Post a Comment