How to get values from people field of a list using REST API ?

Get values from people or group field of a list using REST API:

Generally, when we try to get value from a people or group field then we get id of people value/id of user. Id of User is coming as same as we get when we try to get value from lookup field. 


The below is the Image of People Field - Contractor Name (internal name-Contractor_x0020_Name) from list - User Data 
Problem REST APL
url _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/getbytitle('User Data')/items"

Solution REST APL
url _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/getbytitle('User Data')/items?$select=*,Contractor_x0020_Name/Title&$expand=Contractor_x0020_Name"


$.ajax({
 url: url,
 type: "GET",
 headers: { "ACCEPT": "application/json;odata=verbose" },
 success: function(data)
   console.log(data);
    data.d.results.forEach(function(res){
        console.log(res);
    });
 },
 error:  function(data){
   console.log(JSON.stringify(data));
 }
});

Output:

When we use Problem REST API then result as shown below

When we use Solution REST API then result as shown below



 or






Comments

Popular posts from this blog

Get list item entity type full name of a SharePoint list using REST API

Get SharePoint list name by GUID

Get Current Web Logged In User of SharePoint Site in jQuery