4

I'm in struggle to retrieving all user profiles in a single request. Is it possible to retrieve all user profiles including properties with REST search API?

2 Answers 2

2

Did not find any REST API which can find all users' profile in a single request.

But we can search in the User Profile using REST API. Following is the end-point of searching user's profile including properties.

"/_api/search/query?querytext='whatToSearch'&sourceid='b09a7990-05ea-4af9-81ef-edfab16c4e31'&rowlimit='100'&selectproperties='PictureURL, PreferredName, Country'"

Another thing we can find all site users by following APIs

_api/web/siteusers

OR

/_vti_bin/ListData.svc/UserInformationList
0

https://codeplayandlearn.wordpress.com/2015/11/28/get-user-profile-properties-from-sharepoint-online-using-csom-console-application/

Get User Collection
 UserCollection users = tenantContext.Web.SiteUsers;
                tenantContext.Load(users);
                tenantContext.ExecuteQuery();

Get Personal Propertie of user

 PeopleManager peopleManager = new PeopleManager(tenantContext);
PersonProperties personProperties = peopleManager.GetMyProperties();
 tenantContext.Load(personProperties);
                tenantContext.ExecuteQuery();




  string[] userProfileProperties = new string[personProperties.UserProfileProperties.Count+1];

        // string[] userProfileProperties = { "AccountName", "FirstName", "LastName", "PreferredName", "Manager", "AboutMe",

"PersonalSpace", "PictureURL", "UserName", "WorkEmail", "SPS-Birthday" }; int i = 0; foreach (string key in personProperties.UserProfileProperties.Keys) {

            userProfileProperties[i] = key;
            i++;
        }


        foreach (string propertyKey in userProfileProperties)
        {
            items.Append(propertyKey);
            items.Append(",");
        }
        items.AppendLine();

foreach (Microsoft.SharePoint.Client.User user in users)
                {
                    try
                    {
                        if (user.PrincipalType != Microsoft.SharePoint.Client.Utilities.PrincipalType.User) continue;

                        UserProfilePropertiesForUser userProfilePropertiesForUser = new

UserProfilePropertiesForUser(tenantContext, user.LoginName, userProfileProperties); IEnumerable profileProperties = peopleManager.GetUserProfilePropertiesFor(userProfilePropertiesForUser); tenantContext.Load(userProfilePropertiesForUser); tenantContext.ExecuteQuery(); foreach (string property in profileProperties) { items.Append(property); items.Append(","); } items.AppendLine(); } catch (Exception ex) { throw ex; }

                }

you will get all user Properties with username

Thanks

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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