Get Login Name and Display Name by User ID using SharePoint 2013 REST API

We can pass the user id to the below function & we can get the user name.

function getUser(id){
var returnValue;
  jQuery.ajax({
   url: "http://YourSite/_api/Web/GetUserById(" + id + ")",
   type: "GET",
   headers: { "Accept": "application/json;odata=verbose" },
   success: function(data) {
           var dataResults = data.d;
      //get login name
      var loginName  = dataResults.LoginName.split('|')[1];
      alert(loginName);  
      //get display name
      alert(dataResults.Title);
   }
 });
}


Please refer this link for more details Link1

Comments

Popular posts from this blog

Upload Single/Multiple file by using the REST API and jQuery SharePoint 2013

A type named 'SP.Data. could not be resolved by the model error

Add content type to SharePoint List/Library using REST API