3

I have to fetch the User Profiles(selected) with filters-

First_Name starts with A or
Department_Name = "Test" or 
Last_Name contains A

and get the count of those users with API.

Can you guide me for the exact root?

  • Use startsWith with $filter and end-point will be /_vti_bin/ListData.svc/UserInformationList – Atish Dipongkor - MVP Sep 27 '16 at 5:50
  • Can you please share some references, so that I can do that? – Ram Sep 27 '16 at 5:51
  • wait answering your question – Atish Dipongkor - MVP Sep 27 '16 at 5:53
  • check my answer if it is helpful for you – Atish Dipongkor - MVP Sep 27 '16 at 6:00
7

I use UserInformationList for User Profile properties. Your requirement can be achieved using $filter operator.

/_vti_bin/ListData.svc/UserInformationList?$filter=startswith(FirstName,'A') or Department eq '{Department Name}' or startswith(LastName, 'A')

Total count will be response.d.results.length.

You have to make a GET request in above end-point. For testing/exploring, you can use my SharePoint REST Client.

There is another end-point /_api/SP.UserProfiles.PeopleManager/GetPropertiesFor to get particular user profile properties by its login name.

Find more about $filter in my article CRUD Operation to List Using SharePoint 2013 Rest API

  • The problem with this approach is i will not return all user profiles. Only those that have participated in your target site. – Matthew McDermott Sep 27 '16 at 12:31
  • That is true. _api/search/query has a problem also. lookup columns can not be expanded. – Atish Dipongkor - MVP Sep 28 '16 at 6:26
  • What lookup columns are you referring to? – Matthew McDermott Sep 28 '16 at 12:15
  • Manager or CreatedBy – Atish Dipongkor - MVP Sep 28 '16 at 12:23
3

You can use the search API and REST or CSOM to achieve this:

https://<your tenant url>/_api/search/query?querytext='FirstName=A* OR Department=Test OR LastName:A'&selectproperties='LastName,FirstName,Department'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'

The SourceId parameter ensures that you are searching User Profiles.

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.