Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
SharePoint REST API - Get User Properties And User Information List
WhatsApp
Ramakrishnan R
3y
114.4
k
0
6
25
Blog
Hey there!!
In this blog, we are going to see how can we fetch
User Names and User Emails
using a
REST API
call that displays particular user information.
In SharePoint, you can access the
User Information List
to get basic data about a user.
This list is hidden and there’s no direct link provided by Microsoft to access the list, which I will discuss later in this blog.
To get the user Name and Email, we are going to use the endpoint,
_spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + UserID + ")";
JavaScript Code
function
fnGetUserProps() {
var
UserID = _spPageContextInfo.userId;
var
requestUri = _spPageContextInfo.webAbsoluteUrl +
"/_api/web/getuserbyid("
+ UserID +
")"
;
$.ajax({
url: requestUri,
type:
"GET"
,
headers: {
"Accept"
:
"application/json; odata=verbose"
},
async:
false
,
success:
function
(data) {
var
userName = data.d.Title;
var
userEmail = data.d.Email;
alert(
userName+' '+
userEmail
);
},
error:
function
(error) {
console.log(
"fnGetUserProps:: "
+ error);
}
});
}
REST API to Get all properties of the current user,
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties
REST API to Get all properties of Specific User,
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|
[email protected]
'
For more information refer the URL below,
https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn790354(v=office.15)?redirectedfrom=MSDN#bk_PeopleManagerGetPropertiesFor
User Information List
The User Information List is hidden which resides only in Root Site Collection and contains data about the user added as part of their
Active Directory (AD) profile configuration
,
users don’t have a direct link to access it.
Whenever you grant access to the user on the SharePoint site/list or the other resource, the user automatically gets added to the present list.
If any AD Group is given permission on-site, the group also will be added to the User Information List, and also the Group-users are going to be added to the list.
You can
access the User Information list
as long as
you're an Admin of the location.
To access User Information List
Get detailed information for users -
https://SiteURL/_catalogs/users/detail.aspx
Get basic information for users -
https://SiteURL/_catalogs/users/simple.aspx
Access SharePoint User Information List
Using REST API
function
fnGetAllFields() {
$.ajax({
url: _spPageContextInfo.siteAbsoluteUrl +
"/_api/web/lists/getByTitle('User Information List')/fields"
,
method:
"GET"
,
headers: {
"Accept"
:
"application/json;odata=verbose"
},
success:
function
(data) {
var
dataResults = data.d.results;
for
(
var
i = 0; i < dataResults.length; i++) {
console.log(dataResults[i][
"Title"
]);
}
},
error:
function
(error) {
console.log(
"Failed"
);
}
});
}
Happy Learning!!!
SharePoint
Microsoft
REST API
Up Next
Getting Current Logged In User Using Rest API In SharePoint Online And Get User Details Using User ID
Ebook Download
View all
SharePoint Online And Office 365 Administration
Read by 3.6k people
Download Now!
Learn
View all
HexaCorp
Expertise in the cloud, speed of innovation and customer focus on building strong relationships
Membership not found