I'd like to get all user profiles filtered by a specific property (department for instance) using REST. Is that possible? In my dreams:
_api/SP.UserProfiles.PeopleManager/GetUsersByProperty(MyProperty='X')
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityYes, it is possible, but you need to use slightly different approach.
You can use search in order to filter users by profile property. Normally core profile properties are mapped to corresponding managed properties in search. If you are using custom profile properties, you need to make sure that this mappings exist or create it if it's missing.
Then you can run search query to find all people with profile property.
For example following query searches all people by acccount name mask:
https://mysp.sharepoint.com/sites/dev/_api/search/query?querytext='accountname:"*john*"'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'
this guid B09A7990-05EA-4AF9-81EF-EDFAB16C4E31
is reference people search results.
Later you need to parse search result, grab AccountName
and then use rest to query particular user profile and extract properties.
A bit more samples and info here - Working with People Search and User Profiles
*
to query all users and see the properties - https://sp.sharepoint.com/sites/dev/_api/search/query?querytext='*"'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'
Nov 9, 2016 at 15:06