SharePoint 2013: Get User Details from Person or Group field using REST API
This article helps to understand, how to get user details like FirstName, LastName, Email Address etc. for a Person/Group field using REST API.
Normally, in a list where we have Person/Group column (say Employee), when we use REST API to get this column value, we get User ID instead of actual value what we see in list column. Reason being Person/Group column is actually a lookup field internally.
Say I have a list Employees with column "Users", and for one item value for Users is "Danish Islam" (set to Name with Presence property).
Now if I query this list using below REST API -
_api/web/lists/getbytitle('employees')/items
I see the result as in the screenshot below
Here if you observe, Users column is returned as "UsersId" and with value "10" not the actual value.
Now if I want the actual value, I have to modify my query something like below-
**_api/web/lists/getbytitle('employees')/items?$select=Users/Title&$expand=Users/Id
**
See the highlighted change, this will return the exact value like below-
Similarly, If I want to display Email Address or First Name or Last Name, I just have to replace keyword after column name - Title after Users. See below example-
Query:
_api/web/lists/getbytitle('employees')/items?$select=Users/EMail,Users/FirstName,Users/LastName,Users/EMail&$expand=Users/Id
**Result: **
Some of the properties that can be used are mentioned below-
S.No | Property |
1 | Id |
2 | ContentTypeID |
3 | ContentType |
4 | Name |
5 | Modified |
6 | Created |
7 | Account |
8 | |
9 | MobileNumber |
10 | AboutMe |
11 | SIPAddress |
12 | IsSiteAdmin |
13 | Deleted |
14 | Hidden |
15 | Picture |
16 | Department |
17 | JobTitle |
18 | LastName |
19 | FirstName |
**References:
**
- https://msdn.microsoft.com/en-us/library/office/jj860569.aspx
- https://msdn.microsoft.com/en-us/library/office/jj164022.aspx
- https://msdn.microsoft.com/en-us/magazine/dn198245.aspx
Hope this is helpful.