0

I'm trying to get user's information using REST call to a list. The list named "Members" has two fields:

Team: Single line of text

User: Person or group

The code piece for REST call is below:

var queryUrl = "<web url>/_api/web/lists/getbytitle('Members')/items?$select=User/UserName,User/EMail&$expand=User";

jQuery.ajax({
    url: queryUrl,
    type: "GET",
    headers: {
        Accept: "application/json;odata=verbose"
    },
    async: false,
    success: function (response) {
        console.log(response.d.results);                        
    },
    error: function (response) {
        console.log(response);          
    }
});

There are few items in the 'Members' list. The issue I'm facing is that for some users the 'User/UserName' value is returned null.

How can I debug the issue?

1

There could be a case that username is empty in UserProfile.

Try to fetch other user properties:

$select=Users/EMail,Users/FirstName,Users/LastName&$expand=Users

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.