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,

Join the conversation! Your thoughts help the community grow.